Skip to content

Allow non-scalar directive arguments and variables #4

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

csboling
Copy link

@csboling csboling commented Jul 6, 2018

The approach of copying the directive args from the document to the args object passed to the resolver (args[arg.name.value] = arg.value.value;) only works for scalar argument types, because in the case of a ListValueNode the prop is called values, for an ObjectValueNode it is fields, etc., and we would have to descend further into the document to gather the whole structure of the arguments in these cases.

graphql-js exports a helper function getDirectiveValues for exactly this purpose. Using this instead makes it possible for directives to accept arbitrary arguments. I also needed to rewrite parseSchemaDirectives to build the DirectiveDefinitionNodes directly from the user-provided directive configuration, because the existing implementation had some baked-in assumptions about there being a single string argument to the directive.

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.

1 participant