You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I am converting our test suites to mostly use run_graphql_field where we only test a specific field. In some of our types, we're using the lookahead extra to optimize our database queries. When attempting to use the test helper on such a field, graphql-ruby raises an error:
GraphQL::Schema::Field::FieldImplementationFailed:
Failed to call `:some_field` on #<Types::SomeType:0x000000011da57918 @object=#<Some id: 1>, @context=#<Query::Context ...>> because the Ruby method params were incompatible with the GraphQL arguments:
- `lookahead:` is required by Ruby, but not by GraphQL. Consider `lookahead: nil` instead, or making this argument required in GraphQL.
Describe the solution you'd like
A default lookahead being passed in that claims nothing is selected would probably be the best developer experience. Some way of overriding it would make testing the optimizations in the field's method possible, but testing using a full query starting from the QueryType would be acceptable in these cases I think, since it's no longer testing a field in isolation (which seems to be the spirit of the run_graphql_field helper).
Describe alternatives you've considered
For now I'll leave these to execute complete queries against the schema class.
The text was updated successfully, but these errors were encountered:
Hey, thanks for reporting this. I updated run_graphql_field in #4930 to inject minimal objects by default, but accept any object using a keyword argument (run_graphql_field(...., lookahead: ...). It's not easy to make a lookahead without a real query, but for small unit-testing, you could create mock and inject it that way.
Is your feature request related to a problem? Please describe.
I am converting our test suites to mostly use
run_graphql_field
where we only test a specific field. In some of our types, we're using the lookahead extra to optimize our database queries. When attempting to use the test helper on such a field, graphql-ruby raises an error:Describe the solution you'd like
A default lookahead being passed in that claims nothing is selected would probably be the best developer experience. Some way of overriding it would make testing the optimizations in the field's method possible, but testing using a full query starting from the QueryType would be acceptable in these cases I think, since it's no longer testing a field in isolation (which seems to be the spirit of the
run_graphql_field
helper).Describe alternatives you've considered
For now I'll leave these to execute complete queries against the schema class.
The text was updated successfully, but these errors were encountered: