graphql-client
graphql-client copied to clipboard
Can I convert an `IntrospectionResponse` to GraphQL Schema Language?
I've got as far as producing a schema.json
file by sending an introspection query to my backend with graphql-client
, but I want to produce a schema.graphql
file; ~or anything that will allow me to traverse the GraphQL schema easily client-side~. Is there a simple way to do this? graphql_client_codegen
seems to have the functionality but it's all private.
Basically my end objective is to generate a schema.graphql
file and Typescript types from a GraphQL schema. I'm aware of graphql-codegen
, I just want to make my own implementation.
(Edit: I'm a fool, I've realised IntrospectionResponse
is good enough for traversing)
@Teajey Have you found a solution for this? I need some sort of CLI that generate the .graphql file instead of the .json one.
@Teajey Have you found a solution for this? I need some sort of CLI that generate the .graphql file instead of the .json one.
I wrote a module that converts the Schema
component of my introspection response to graphql_parser::schema::Document
, and I can use that to generate the GraphQL AST using it's Display
implementation. You can find the code here: https://github.com/Teajey/graft/blob/master/packages/graft/src/graphql/schema/to_document.rs