Skip to content

Allow non-scalar directive arguments and variables#4

Open
csboling wants to merge 2 commits into
lirown:masterfrom
csboling:complex-arg-types
Open

Allow non-scalar directive arguments and variables#4
csboling wants to merge 2 commits into
lirown:masterfrom
csboling:complex-arg-types

Conversation

@csboling

@csboling csboling commented Jul 6, 2018

Copy link
Copy Markdown

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