Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix run_graphql_field with missing query string on dummy query #4891

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

ryanseys
Copy link
Contributor

Bug: The dummy_query object created as part of run_graphql_field doesn't set a query string, which results in a query_context object that has validation errors.

Later when object_type.wrap(inner_object, query_context) is called with that query_context, it checks that the field is authorized.

If as part of checking self.authorized? on an object, we first ensure that the context is valid i.e. that context.errors.empty?, we will find that it isn't because of this missing query string.

Even if this query string isn't used, the GraphQL::Query object should be valid, in case there are validations that are done on these objects in a client's code. This is what we are doing in our code, which led me to this bug.

This PR sets a dummy query string value to fix this issue, and adds a simple self.authorized? check which ensures that the context is valid i.e. that context.errors.empty?

@ryanseys ryanseys changed the title Add dummy query string to dummy query to pass validation errors Fix run_graphql_field with missing query string on dummy query Mar 27, 2024
Co-authored-by: Robert Mosolgo <rdmosolgo@gmail.com>
@ryanseys ryanseys requested a review from rmosolgo March 28, 2024 17:14
@ryanseys
Copy link
Contributor Author

ryanseys commented Mar 28, 2024

Please take another look 😄

@rmosolgo rmosolgo added this to the 2.3.1 milestone Mar 28, 2024
@rmosolgo
Copy link
Owner

Thanks for the fix!

@rmosolgo rmosolgo merged commit 4280468 into rmosolgo:master Mar 28, 2024
12 checks passed
@ryanseys ryanseys deleted the rs-fix-query branch April 26, 2024 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants