Skip to content

Schema directives do not support EnumValue arguments #1500

Closed

Description

@lkorth

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?

/**
* 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());
}

Activity

  1. andimarek commented on Jul 19, 2019

    @andimarek
    Member

    I don't see a reason why this should be restricted ... but @bbakerman has the full context.

  2. AnkBurov commented on Nov 28, 2019

    @AnkBurov

    +++
    Is there really a reason for that?

  3. andimarek commented on Dec 24, 2019

    @andimarek
    Member

    this is a bug we will fix: directives support enum args.

  4. added this to the 14.0 milestone on Jan 9, 2020
  5. andimarek commented on Jan 16, 2020

    @andimarek
    Member

    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)

  6. removed this from the 14.0 milestone on Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions