Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I convert an IntrospectionResponse to GraphQL Schema Language? #438

Open
Teajey opened this issue Oct 15, 2022 · 2 comments
Open

Can I convert an IntrospectionResponse to GraphQL Schema Language? #438

Teajey opened this issue Oct 15, 2022 · 2 comments

Comments

@Teajey
Copy link

Teajey commented Oct 15, 2022

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)

@omarabid
Copy link

@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
Copy link
Author

Teajey commented Jun 20, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants