Skip to content

Schema deserialization crashes on directive location DIRECTIVE_DEFINITION #176

Description

@dil-adatoth

Summary

Generation fails immediately with a JsonSerializationException when the target schema's introspection contains the directive location DIRECTIVE_DEFINITION. This value is a valid member of the GraphQL spec's __DirectiveLocation enum (one of the 12 TypeSystemDirectiveLocation values), but the generator's GraphQlDirectiveLocation enum does not include it, so schema deserialization throws before any code is generated.

Per the GraphQL specification, __DirectiveLocation includes these TypeSystemDirectiveLocation values:

SCHEMA, SCALAR, OBJECT, FIELD_DEFINITION, ARGUMENT_DEFINITION, INTERFACE, UNION, ENUM, ENUM_VALUE, INPUT_OBJECT, INPUT_FIELD_DEFINITION, DIRECTIVE_DEFINITION

DIRECTIVE_DEFINITION is spec-valid and commonly emitted — e.g. the built-in @deprecated directive is valid on it. Any server that reports it will crash the generator during introspection deserialization.

Source:

Version

graphql-client-generator 0.9.31 (0.9.31+5577b29fa4bff48a6e24fbce3bfec8c48a05e101)

Error / stack trace

Unhandled exception: Newtonsoft.Json.JsonSerializationException: Error converting value "DIRECTIVE_DEFINITION" to type 'GraphQlClientGenerator.GraphQlDirectiveLocation'. Path 'data.__schema.directives[2].locations[4]'.
 ---> System.ArgumentException: Requested value 'DIRECTIVE_DEFINITION' was not found.
   at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(...)
   at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(...)
   ...
   at GraphQlClientGenerator.GraphQlHttpUtilities.DeserializeGraphQlSchema(String contentJson)
      in /_/src/GraphQlClientGenerator/GraphQlHttpUtilities.cs:line 82
   at GraphQlClientGenerator.GraphQlHttpUtilities.RetrieveSchema(...)
      in /_/src/GraphQlClientGenerator/GraphQlHttpUtilities.cs:line 75

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions