You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug dotnet-graphql crashes when downloading schema from Hasura. This is because Hasura has directives that don't specify whether they are repeatable or not. See the additional context at the bottom of this bug report, where I fixed the issue (but I don't know if this is the fix you guys want).
To Reproduce
Steps to reproduce the behavior:
Create a directory on your local machine
Download the following docker-compose.yml file to it:
version: '3'
volumes:
postgres-data:
pgadmin:
services:
postgres:
image: postgres:13
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U MyApplication"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "5432:5432"
environment:
POSTGRES_USER: MyApplication
POSTGRES_PASSWORD: changeme
POSTGRES_DB: MyApplication
volumes:
- postgres-data:/var/lib/postgresql/data
- ./postgres-backups:/var/lib/pgadmin/storage
graphql-engine:
image: hasura/graphql-engine:v2.0.0-alpha.8
ports:
- "8080:8080"
depends_on:
- postgres
restart: always
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://MyApplication:changeme@postgres:5432/MyApplication
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
Run the following commands in that directory:
docker-compose up
dotnet new tool-manifest
dotnet tool install StrawberryShake.Tools --local
dotnet graphql init http://localhost:8080/v1/graphql
Notice the following exception displayed by dotnet-graphql:
Download schema started.
Download schema completed in 158 ms
Unhandled exception. System.Text.Json.JsonException: The JSON value could not be converted to System.Boolean. Path: $.data.schema.directives[0].isRepeatable | LineNumber: 0 | BytePositionInLine: 226.
---> System.InvalidOperationException: Cannot get the value of a token type 'Null' as a boolean.
at System.Text.Json.Utf8JsonReader.GetBoolean()
at System.Text.Json.Serialization.Converters.BooleanConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.Converters.IEnumerableDefaultConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase)
at System.Text.Json.JsonSerializer.ReadAsync[TValue](Stream utf8Json, Type returnType, JsonSerializerOptions options, CancellationToken cancellationToken)
at HotChocolate.Utilities.Introspection.IntrospectionClient.ExecuteIntrospectionAsync(HttpClient client, HttpQueryRequest request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionClient.cs:line 144
at HotChocolate.Utilities.Introspection.IntrospectionClient.DownloadSchemaAsync(HttpClient client, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionClient.cs:line 73
at HotChocolate.Utilities.Introspection.IntrospectionClient.DownloadSchemaAsync(HttpClient client, Stream stream, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionClient.cs:line 49
at StrawberryShake.Tools.DefaultFileSystem.WriteToAsync(String fileName, Func`2 write) in /home/vsts/work/1/s/src/StrawberryShake/Tooling/src/dotnet-graphql/DefaultFileSystem.cs:line 81
at StrawberryShake.Tools.IntrospectionHelper.DownloadSchemaAsync(HttpClient client, IFileSystem fileSystem, IActivity activity, String fileName, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/StrawberryShake/Tooling/src/dotnet-graphql/IntrospectionHelper.cs:line 21
at StrawberryShake.Tools.InitCommandHandler.DownloadSchemaAsync(InitCommandContext context, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/StrawberryShake/Tooling/src/dotnet-graphql/InitCommandHandler.cs:line 92
at StrawberryShake.Tools.InitCommandHandler.ExecuteInternalAsync(InitCommandContext context, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/StrawberryShake/Tooling/src/dotnet-graphql/InitCommandHandler.cs:line 64
at StrawberryShake.Tools.InitCommandHandler.ExecuteAsync(InitCommandArguments arguments, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/StrawberryShake/Tooling/src/dotnet-graphql/InitCommandHandler.cs:line 50
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at StrawberryShake.Tools.Program.<Main>(String[] args)
Expected behavior
I expected the Hasura schema to be downloaded to schema.graphql
Desktop (please complete the following information):
OS: Manjaro Linux
Version: 21.0.2
Additional context
I have a fix for this which basically makes the Directive.IsRepeatable property be nullable, and in IntrospectionDeserializer uses a value of false if IsRepeatable is null. Is that the kind of fix you guys think is appropriate?
The text was updated successfully, but these errors were encountered:
Describe the bug
dotnet-graphql
crashes when downloading schema from Hasura. This is because Hasura has directives that don't specify whether they are repeatable or not. See the additional context at the bottom of this bug report, where I fixed the issue (but I don't know if this is the fix you guys want).To Reproduce
Steps to reproduce the behavior:
docker-compose.yml
file to it:dotnet-graphql
:Expected behavior
I expected the Hasura schema to be downloaded to
schema.graphql
Desktop (please complete the following information):
Additional context
I have a fix for this which basically makes the
Directive.IsRepeatable
property be nullable, and inIntrospectionDeserializer
uses a value of false ifIsRepeatable
is null. Is that the kind of fix you guys think is appropriate?The text was updated successfully, but these errors were encountered: