Repository navigation
Schema directives do not support EnumValue arguments #1500
Copy link
Copy link
Closed
Description
Schema directives currently only support built in scalars, are there any plans to add support for enums or any reason I shouldn't take a crack at adding them?
graphql-java/src/main/java/graphql/schema/idl/SchemaGeneratorHelper.java
Lines 155 to 183 in bd9240c
| /** | |
| * We support the basic types as directive types | |
| * | |
| * @param value the value to use | |
| * | |
| * @return a graphql input type | |
| */ | |
| public GraphQLInputType buildDirectiveInputType(Value value) { | |
| if (value instanceof NullValue) { | |
| return Scalars.GraphQLString; | |
| } | |
| if (value instanceof FloatValue) { | |
| return Scalars.GraphQLFloat; | |
| } | |
| if (value instanceof StringValue) { | |
| return Scalars.GraphQLString; | |
| } | |
| if (value instanceof IntValue) { | |
| return Scalars.GraphQLInt; | |
| } | |
| if (value instanceof BooleanValue) { | |
| return Scalars.GraphQLBoolean; | |
| } | |
| if (value instanceof ArrayValue) { | |
| ArrayValue arrayValue = (ArrayValue) value; | |
| return list(buildDirectiveInputType(getArrayValueWrappedType(arrayValue))); | |
| } | |
| return assertShouldNeverHappen("Directive values of type '%s' are not supported yet", value.getClass().getSimpleName()); | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
andimarek commentedon Jul 19, 2019
I don't see a reason why this should be restricted ... but @bbakerman has the full context.
AnkBurov commentedon Nov 28, 2019
+++
Is there really a reason for that?
andimarek commentedon Dec 24, 2019
this is a bug we will fix: directives support enum args.
andimarek commentedon Jan 16, 2020
Closing this because directives with enum args are supported.
See this test:
https://github.com/graphql-java/graphql-java/blob/master/src/test/groovy/graphql/schema/idl/SchemaGeneratorTest.groovy#L2029
The mentioned code snippet is not actually used when you declare a directive. This is some old code which will be deleted soon and was meant to deal with cased where you actually don't declare your directive at all (this was before SDL was part of the official spec)