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

Remove unused variables from queries #518

Merged
merged 5 commits into from
Aug 9, 2016
Merged

Conversation

Slava
Copy link
Contributor

@Slava Slava commented Aug 8, 2016

TODO:

  • Update CHANGELOG.md with your change
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

After diffing queries, removing parts that could be queried from the store,
some variables in the query can become unused, causing errors pointing
out unused variables.

This patch, walks the query and fragments asts and filters out the variables
no longer used.

After diffing queries, removing parts that could be queried from the store,
some variables in the query can become unused, causing errors pointing
out unused variables.

This patch, walks the query and fragments asts and filters out the variables
no longer used.
@Slava
Copy link
Contributor Author

Slava commented Aug 8, 2016

Fixes #496

return uniq(variables);
}

export function removeUnusedVariablesFromDiffedQuery (
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "diffed" from this name - since it doesn't really have anything to do with diffed queries.

if (field.arguments) {
variables = flatten(field.arguments.map((arg) => {
if (arg.value.kind === 'Variable') {
return [(arg.value as any).name.value];
Copy link
Contributor

Choose a reason for hiding this comment

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

Use Variable instead of any

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants