Closed bmulholland closed 3 months ago
Should it just become
sig { params(query_str: String, kwargs: T.untyped).returns(T.any(T::Hash[String, T.untyped], GraphQL::Query::Result)) }
?
I could submit a PR for that
I'm surprised given this but if that's the type in runtime yes you can open a PR with that sig.
What's surprising about the line you linked?
execute
returns multiplex
which returns Interpreter#run_all
which looks like it's returning an array. Yard documentation matches this too.
Ah yeah -- based on that it would be confusing. Maybe you missed the next line, which takes the first element from that array?
Hmm wouldn't that element be a Hash
or a Query
?
But feel free to open the PR and I'll do a runtime test to make sure. As long as it's correct and doesn't degrade the more common usage of Hash
it should be okay.
I filed an issue over at the GraphQL repo and they've actually replaced the return type to be exclusively a Result, not ever a Hash. https://github.com/rmosolgo/graphql-ruby/pull/4984
Following that, unless you see something I'm not, I'll change the type in my PR to always be a Result. Any concerns with that?
Thanks. Yes let's do Result.
Awesome. Updated the attached PR :)
Problem
https://github.com/Shopify/rbi-central/blob/main/rbi/annotations/graphql.rbi#L16 is missing at least one possible return type: GraphQL::Query::Result. https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/execution/interpreter.rb#L128
We use that in our app, for GraphQL subscriptions via ActionCable channels, ref: https://graphql-ruby.org/api-doc/1.11.5/GraphQL/Subscriptions/ActionCableSubscriptions
Context