When converting from schema in SDL (.graphql) to json using the introspection query with fromSchemaDefinition it doesn't seem to work if the schema has either interfaces or unions. The reason behind this is that graphql-dotnet expects to see either ResolveType on the parent type (union or interface) or IsTypeOf on the union cases/interface implementations. And when doing GraphQL.Types.Schema.For(definition) both ResolveType and IsTypeOf end up being null which later makes the introspection query in fromSchemaDefinition fail with InvalidOperationException. SchemaTypes from graphql-dotnet throws exception for union types and for interface types.
This is not applicable in case of introspection query when no actual data is involved and there is nothing to resolve, which is the case with fromSchemaDefinition. We bypass the validation by always providing a dummy ResolveType which is only used for interfaces and unions to resolve mapping between the actual data and the corresponding GraphTypes when creating a graphql api with graphql-dotnet.
Thank a lot @MargaretKrutikova for investigating the problem and for the fix 🙏 I've merged your PR and published Snowflaqe v1.37 🚀 please take it for a spin and let me know if you encounter any issues
Fixes #70 .
When converting from schema in SDL (
.graphql
) tojson
using the introspection query withfromSchemaDefinition
it doesn't seem to work if the schema has either interfaces or unions. The reason behind this is thatgraphql-dotnet
expects to see eitherResolveType
on the parent type (union or interface) orIsTypeOf
on the union cases/interface implementations. And when doingGraphQL.Types.Schema.For(definition)
bothResolveType
andIsTypeOf
end up beingnull
which later makes the introspection query infromSchemaDefinition
fail withInvalidOperationException
.SchemaTypes
fromgraphql-dotnet
throws exception for union types and for interface types.This is not applicable in case of introspection query when no actual data is involved and there is nothing to resolve, which is the case with
fromSchemaDefinition
. We bypass the validation by always providing a dummyResolveType
which is only used for interfaces and unions to resolve mapping between the actual data and the correspondingGraphType
s when creating a graphql api withgraphql-dotnet
.