Type collection and reference replacement does not descend into directive arguments · Issue #1208 · graphql-java/graphql-java · GitHub
Skip to content

Type collection and reference replacement does not descend into directive arguments #1208

Description

@kaqqao

Seems like neither GraphQLTypeCollectingVisitor nor GraphQLTypeResolvingVisitor visit directive arguments at all.
As a result, a type that is used in directive arguments only does not become a part of the schema i.e. schema.getTypeMap() will not contain it.
Neither will a type reference used in a directive argument get replaced.

Here's a quick example:

GraphQLSchema schema = GraphQLSchema.newSchema()
                .query(GraphQLObjectType.newObject()
                        .name("Query")
                        .field(GraphQLFieldDefinition.newFieldDefinition()
                                .name("test")
                                .type(Scalars.GraphQLString)
                                .argument(GraphQLArgument.newArgument()
                                        .name("in")
                                        //Gets replaced as expected
                                        .type(new GraphQLTypeReference("String"))
                                )
                                .dataFetcher(env -> "test")
                                .withDirective(GraphQLDirective.newDirective()
                                        .name("auth")
                                        .argument(GraphQLArgument.newArgument()
                                                .name("role")
                                                //Does *not* get replaced
                                                .type(new GraphQLTypeReference("String"))
                                                .value("Admin")
                                        )
                                )
                        )
                )
                .build();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions