Summary
The 3.2.11 release added support for directives on directive definitions ("Add support for directives on directive definitions"). As a side-effect, the @deprecated built-in directive now includes DIRECTIVE_DEFINITION in its reported locations when queried via __schema introspection.
Steps to reproduce
Run an introspection query against any server using graphql-core 3.2.11:
curl -s 'https://your-server/graphql' \
-H 'Content-Type: application/json' \
-d '{"query":"{ __schema { directives { name locations } } }"}' | python3 -m json.tool
You will see the @deprecated directive now includes DIRECTIVE_DEFINITION in its locations:
{
"name": "deprecated",
"locations": [
"FIELD_DEFINITION",
"ARGUMENT_DEFINITION",
"INPUT_FIELD_DEFINITION",
"ENUM_VALUE",
"DIRECTIVE_DEFINITION"
]
}
Impact
This breaks GraphQL codegen tools (e.g. @graphql-codegen/cli / yarn codegen) that do not expect DIRECTIVE_DEFINITION as a valid location for @deprecated. These tools fail with an error when they encounter this unexpected location in the introspection result.
The GraphQL June 2018 spec and the current stable (October 2021) spec do not include DIRECTIVE_DEFINITION as a valid location for @deprecated. This change therefore introduces a spec-incompatible introspection response that causes real-world tooling breakage.
Expected behaviour
@deprecated should only report locations that are included in the spec it claims to implement (June2018/October2021). DIRECTIVE_DEFINITION should not be listed unless the schema explicitly declares it.
Workaround
Pin graphql-core<3.2.11.
Environment
- graphql-core: 3.2.11
- Python: 3.11+
- Codegen tool: @graphql-codegen/cli (yarn codegen)
Summary
The 3.2.11 release added support for directives on directive definitions ("Add support for directives on directive definitions"). As a side-effect, the
@deprecatedbuilt-in directive now includesDIRECTIVE_DEFINITIONin its reportedlocationswhen queried via__schemaintrospection.Steps to reproduce
Run an introspection query against any server using graphql-core 3.2.11:
You will see the
@deprecateddirective now includesDIRECTIVE_DEFINITIONin its locations:{ "name": "deprecated", "locations": [ "FIELD_DEFINITION", "ARGUMENT_DEFINITION", "INPUT_FIELD_DEFINITION", "ENUM_VALUE", "DIRECTIVE_DEFINITION" ] }Impact
This breaks GraphQL codegen tools (e.g.
@graphql-codegen/cli/ yarn codegen) that do not expectDIRECTIVE_DEFINITIONas a valid location for@deprecated. These tools fail with an error when they encounter this unexpected location in the introspection result.The GraphQL June 2018 spec and the current stable (October 2021) spec do not include
DIRECTIVE_DEFINITIONas a valid location for@deprecated. This change therefore introduces a spec-incompatible introspection response that causes real-world tooling breakage.Expected behaviour
@deprecatedshould only report locations that are included in the spec it claims to implement (June2018/October2021).DIRECTIVE_DEFINITIONshould not be listed unless the schema explicitly declares it.Workaround
Pin
graphql-core<3.2.11.Environment