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

AddArgumentsAsVariables assumes operation.variableDefinitions an array #804

Closed
jakealbert opened this issue May 24, 2018 · 5 comments
Closed
Labels
bug help wanted Extra attention is needed

Comments

@jakealbert
Copy link

I'm hitting a case where the query operation.variableDefinitions is null, but the AddArgumentsAsVariables transformer calls .map and .concat.

It's not immediately clear whether AddArgumentsAsVariables should be checking for null or if variableDefinitions should always be an array. From the graphql-tag README, it certainly seems valid for variableDefinitions to be null.

@ostrgard
Copy link

ostrgard commented Jun 12, 2018

I'm having this same issue and have a hard time finding a workaround. Did you find one, @jakealbert?

@jakealbert
Copy link
Author

jakealbert commented Jun 12, 2018

You can hack the AST definitions from the context of validationRules:

const validationRules = [
  context => {
    context._ast.definitions.forEach(definition => {
      definition.variableDefinitions = definition.variableDefinitions || []
    })
    return true
  }
]

then pass validationRules along with your schema:

graphqlExpress(req => ({ schema, validationRules }))

@ostrgard
Copy link

Thanks a lot, @jakealbert!

@stubailo
Copy link
Contributor

Does anyone want to sent a PR with a fix? Should be like, one line to guard against null in that code.

@stubailo stubailo added bug help wanted Extra attention is needed labels Jul 13, 2018
@yaacovCR
Copy link
Collaborator

yaacovCR commented Apr 1, 2020

Review of current code in next branch looks ok, seems to be fixed by #1306

@yaacovCR yaacovCR closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants