Skip to content

CapabilityInspector and null "__type" responses #8947

@wizzfizz2097

Description

@wizzfizz2097

Product

Strawberry Shake

Version

15.1.11

Link to minimal reproduction

https://gist.github.com/wizzfizz2097/eb3b415af07bc0c47ad03430ccfc6dc5#file-introspection-bash

Steps to reproduce

  1. Start a new project
  2. Add StrawberryShake tooling and client package
  3. Attempt to perform introspection init or download on a public schema: https://partner.thetradedesk.com/v3/graphql-schema

What is expected?

To create the client without an exception, or to provide a helpful message regarding the failure.

What is actually happening?

I believe some of the queries within HotChocolate.Utilities.Introspection.CapabilityInspector are not handling a property in the response that exists, but has a null value. For example the following response when running the query from inspect_directive_type.graphql
{ "data": { "__type": null } }

Relevant log output

dotnet : Unhandled exception. System.InvalidOperationException: The requested operation requires an element of type 'Object', but the target element has type 'Null'.
At line:1 char:1
+ dotnet graphql init https://partner.thetradedesk.com/v3/graphql-schem ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Unhandled excep...as type 'Null'.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
   at System.Text.Json.ThrowHelper.ThrowJsonElementWrongTypeException(JsonTokenType expectedType, JsonTokenType actualType)
   at System.Text.Json.JsonDocument.TryGetNamedPropertyValue(Int32 index, ReadOnlySpan`1 propertyName, JsonElement& value)
   at System.Text.Json.JsonElement.TryGetProperty(String propertyName, JsonElement& value)
   at HotChocolate.Utilities.Introspection.CapabilityInspector.InspectDirectiveTypeAsync() in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/CapabilityInspector.cs:line 132
   at HotChocolate.Utilities.Introspection.CapabilityInspector.InspectAsync(GraphQLHttpClient client, IntrospectionOptions options, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Utilities/src/Utilities.Introspection/CapabilityInspector.cs:line 33
   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 124
   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.InitCommandHandler.DownloadSchemaAsync(InitCommandContext context, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/InitCommandHandler.cs:line 105
   at StrawberryShake.Tools.InitCommandHandler.ExecuteInternalAsync(InitCommandContext context, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/InitCommandHandler.cs:line 82
   at StrawberryShake.Tools.InitCommandHandler.ExecuteAsync(InitCommandArguments arguments, CancellationToken cancellationToken) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/InitCommandHandler.cs:line 68
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at StrawberryShake.Tools.Program.<Main>(String[] args)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions