Skip to content

dotnet-graphql crashes when schema has deprecated fields with null deprecation reason #8720

@dhrdlicka

Description

@dhrdlicka

Product

Strawberry Shake

Version

15.1.10

Link to minimal reproduction

N/A

Steps to reproduce

We have a GraphQL schema with @deprecated(reason: null) directives like this:

schema {
    query: RootQueryType
}

type RootQueryType {
    hello(name: String @deprecated(reason: null)): String
}

What is expected?

dotnet-graphql should succeed and generate GraphQL schema.

What is actually happening?

dotnet-graphql crashes if an introspected field has isDeprecated set to true but deprecationReason set to null.

Relevant log output

PS> dotnet graphql update
Download schema started.
Download schema completed in 1317 ms
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'value')
   at HotChocolate.Language.StringValueNode..ctor(Location location, String value, Boolean block) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Language/src/Language.SyntaxTree/StringValueNode.cs:line 46
   at HotChocolate.Language.StringValueNode..ctor(String value) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Language/src/Language.SyntaxTree/StringValueNode.cs:line 24
   at HotChocolate.Utilities.Introspection.IntrospectionFormatter.CreateDeprecatedDirective(Boolean isDeprecated, String deprecationReason) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs:line 321
   at HotChocolate.Utilities.Introspection.IntrospectionFormatter.CreateInputValues(IEnumerable`1 fields) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs:line 161
   at HotChocolate.Utilities.Introspection.IntrospectionFormatter.CreateFields(IEnumerable`1 fields) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs:line 212
   at HotChocolate.Utilities.Introspection.IntrospectionFormatter.CreateObject(FullType type) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs:line 194
   at HotChocolate.Utilities.Introspection.IntrospectionFormatter.CreateTypes(FullType type) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs:line 94
   at HotChocolate.Utilities.Introspection.IntrospectionFormatter.CreateTypes(ICollection`1 types)+MoveNext() in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs:line 76
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at HotChocolate.Utilities.Introspection.IntrospectionFormatter.Format(IntrospectionResult result) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs:line 15
   at HotChocolate.Utilities.Introspection.IntrospectionClient.IntrospectServerInternalAsync(GraphQLHttpClient client, IntrospectionOptions options, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionClient.cs:line 129
   at HotChocolate.Utilities.Introspection.IntrospectionClient.IntrospectServerInternalAsync(HttpClient client, IntrospectionOptions options, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionClient.cs:line 73
   at StrawberryShake.Tools.IntrospectionHelper.DownloadSchemaAsync(HttpClient client, IFileSystem fileSystem, IActivity activity, String fileName, Int32 typeDepth, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/IntrospectionHelper.cs:line 20
   at StrawberryShake.Tools.UpdateCommandHandler.DownloadSchemaAsync(UpdateCommandContext context, Uri serviceUri, String schemaFilePath, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/UpdateCommandHandler.cs:line 188
   at StrawberryShake.Tools.UpdateCommandHandler.UpdateSchemaAsync(UpdateCommandContext context, String clientDirectory, GraphQLConfig configuration, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/UpdateCommandHandler.cs:line 109
   at StrawberryShake.Tools.UpdateCommandHandler.UpdateSingleSchemaAsync(UpdateCommandContext context, String clientDirectory, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/UpdateCommandHandler.cs:line 83
   at StrawberryShake.Tools.UpdateCommandHandler.ExecuteAsync(UpdateCommandArguments arguments, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/UpdateCommandHandler.cs:line 46
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at StrawberryShake.Tools.Program.<Main>(String[] args)

Additional context

null deprecation reason should be valid according to the GraphQL spec which defines it as a nullable String:

directive @deprecated(
  reason: String = "No longer supported"
) on FIELD_DEFINITION | ENUM_VALUE

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions