Closed MargaretKrutikova closed 2 years ago
I think I like the first approach better and a PR would be appreciated 👍 less fond of the second approach because then we two ways of inferring types from a schema and I would like to not depend on the parser of graphql-dotnet
Understood, I will prepare a PR with the first approach.
Any particular reason you don't want to depend on the parser from graphql-dotnet
? Just wondering for educational purpose 🙂
Any particular reason you don't want to depend on the parser from graphql-dotnet?
I would rather rely on deriving the types from the result of the standard introspection query because the output of it is predictable and won't change based on different versions of a specific parser, graphql-dotnet
in this case
It got me thinking, can we avoid depending on graphql-dotnet
all together and use some other tool to convert from .graphql
to .json
? Or in the worst case write it ourselves in F#
😆 It seems like we are tweaking graphql-dotnet
to make it become a valid graphql server and the only thing we want from it is the introspection query.
I would rather not have to write and maintain my own parser if possible to replace the one from graphql-dotnet. Tweeking it is a lot easier than rebuilding it, although I agree it is not ideal.
Type generation fails with
Unable to resolve reference to type MyCustomScalar
if the schema contains custom scalars. This happens only if using.graphql
schema when callingIntrospection.fromSchemaDefinition
. The reason for this is that when using schema first ingraphql-dotnet
you have to register your custom scalars directly after parsing the schema, here is the docs and here is how it looks like:I was working on a fix for this and my idea was to parse the schema to get the custom scalars out of it and register the types, which would look like this (pseudocode):
This seems to work, however it does seem pretty inefficient since the schema is parsed many times - first
graphq-dotnet
parses it inGraphQL.Types.Schema.For
, then I parse it again to get the scalars, thenSnowflaqe
parses it once more to convert fromjson
to its internal representation.So I started thinking that maybe we could parse the result of
GraphQLParser.Parser.Parse(definition)
directly into the internal data structuresSnowflaqe
uses for type generation? This of course would only be necessary for schemas defined in.graphql
. Any thoughts on this, @Zaid-Ajaj ?FYI, @Yakimych @danielstarck 🙂