Skip to content

Schema introspection in JSON can return directive definition many times  #3453

@paullarionov

Description

@paullarionov

Describe the bug

Version com.graphql-java:graphql-java:21.3

I faced that JSON schema introspection sometimes returns the same directive many times. This breaks code generation in API clients and many tools like Altair.

It happens both if the directive definition is single in sources, and when there are copies of it.

{
  "data": {
    "__schema": {
      "queryType": {
        "name": "Query"
      },
      "mutationType": null,
      "subscriptionType": null,
      "types": [],
      "directives": [
        {
          "name": "exampleDirective",
          "description": null,
          "locations": [
            "FIELD_DEFINITION"
          ],
          "args": []
        },
        {
          "name": "exampleDirective",
          "description": null,
          "locations": [
            "FIELD_DEFINITION"
          ],
          "args": []
        }
      ]
    }
  }
}

In my production project I have 1 directive, but get 2 copies in JSON introspection.

  • What can be the reason for this?
  • Did you see similar situations?
  • Suppose that it is incorrect behaviour

To Reproduce

  1. Example code: https://github.com/paullarionov/test-graphql-java
  2. Fetch of JSON schema:
./gradlew downloadApolloSchema  --endpoint="http://localhost:8080/graphql"  --schema="schema.json"
  1. Example of broken schema: https://github.com/paullarionov/test-graphql-java/blob/main/schema.json#L1022-L1037

Metadata

Metadata

Assignees

No one assigned

    Labels

    keep-openTells Stale Bot to keep PRs and issues open

    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