I am using graphene-django as my GraphQL server and when it's introspected (via its own command or using apollo-codegen I get a JSON file that is quite similar in structure to a GraphQLSchema however it doesn't have the methods found in GraphQLSchema.
If I try passing the file to mockServer I get errors that it's not compatible. This is the schema: https://gist.github.com/abdulhaq-e/8351f4b6c6ddc0b6fa13e57273de6a13 . I wonder how can I use this schema in mockServer.
P.S graphene-django says that the introspected schema is formatted to be compatible with babel-relay-plugin. If perhaps there is a more standard way for formatting schemas in the awesome GraphQL world, then please include it and I will submit a PR for graphene-django to allow that formatting. Whatever to increase the graphql awesomeness :+1:
hey @abdulhaq-e :)
hmm, i think that you should try convert the introspection result into a textual scheme,
then you can use buildSchema to convert it into GraphQLSchema type :)
please keep us updated im carious now ;)
I just found out the query that gets executed for introspection. It's actually the introspectionQuery defined in the reference graphQl JS implementation. https://github.com/graphql/graphql-js/blob/master/src/utilities/introspectionQuery.js
I'll try to come up with a query that generates a structure similar to ITypeDefinitions
So I found this https://github.com/gabrielf/graphql-schema-from-introspection . It doesn't work for me because I use Relay specification. I think it would be a good idea to merge the linked tool with this repository if @gabrielf and maintainers of this repo agree.
@abdulhaq-e you should be able to mock a schema via introspection really easily:
buildClientSchema from GraphQL.js: https://github.com/graphql/graphql-js/blob/master/src/utilities/buildClientSchema.jsThe GraphQL schema tool you linked is not necessary because those tools are built right into the GraphQL.js reference implementation as I linked above!
@stubailo Thanks a lot. I just tried it and it works perfectly.
I also submitted a PR to document this. https://github.com/apollographql/tools-docs/pull/69
Most helpful comment
@abdulhaq-e you should be able to mock a schema via introspection really easily:
buildClientSchemafrom GraphQL.js: https://github.com/graphql/graphql-js/blob/master/src/utilities/buildClientSchema.jsThe GraphQL schema tool you linked is not necessary because those tools are built right into the GraphQL.js reference implementation as I linked above!