cjoudrey / graphql-schema-linter

Validate GraphQL schema definitions against a set of rules
MIT License
694 stars 62 forks source link

Correctly detect unused object types when using custom schema roots #312

Open cjoudrey opened 2 years ago

cjoudrey commented 2 years ago

Inspired by prior work done in https://github.com/cjoudrey/graphql-schema-linter/pull/266.

This pull request modifies the DefinedTypesAreUsed rule to report unused types named Query, Mutation, and Subscription when the schema is configured to use different root object types.

For example, the following schema would report an error:

# Query is unused and will be reported as so.
type Query {
  a: String
}

type QueryRoot {
  a: String
}

schema {
  query: QueryRoot
}