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(reduced queries): accept selection without directives #17

Closed
wants to merge 2 commits into from

Conversation

sclausen
Copy link

fixes #16

@@ -139,7 +139,7 @@ const hasVariable = (selectionSet, variable) => (
const isVariableInArguments = selection.arguments.some(({ value }) => (
value?.name?.value === variable
));
const isVariableInDirectives = selection.directives.some((directive) => (
const isVariableInDirectives = (selection.directives || []).some((directive) => (
directive.arguments.some(({ value }) => value?.name?.value === variable)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindnektar Or would it be wiser to also check if the directives arguments are also not an array?

@mindnektar
Copy link
Owner

Good idea in theory, but unfortunately it doesn't fix the actual issue. The problem is that the hasVariable implementation assumes every selection it handles to be a field, but it could also be a fragment (or possibly something else). The query reduction feature works only with fields, so if hasVariable is facing anything else, it has to stop its current iteration and assume the variable needs to stay.

@mindnektar mindnektar closed this Apr 21, 2022
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.

Bug: Unable to load any pages of the application
2 participants