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

Use Introspection Query as Schema #65

Open
arahansen opened this issue Oct 9, 2017 · 4 comments
Open

Use Introspection Query as Schema #65

arahansen opened this issue Oct 9, 2017 · 4 comments

Comments

@arahansen
Copy link

I was wondering if its possible to expand the functionality of this tool to be able to ingest an introspection query json similar to how eslint-plugin-graphql handles validation.

For my project, I don't always have the *.gql schema types available locally, but I'm able to grab the introspection query json.

I'd be happy to take a look at adding support if I could maybe get pointed in the right direction for where to start digging in!

@Mayank1791989
Copy link
Owner

Mayank1791989 commented Oct 9, 2017

For my project, I don't always have the *.gql schema types available locally, but I'm able to grab the introspection query json.

You can always convert introspection query json to schema.graphql

import { printSchema, buildClientSchema } from 'graphql';
const schema = printSchema(buildClientSchema(introspectionQueryJSON));
// write schema to schema.graphql and use it

I'd be happy to take a look at adding support if I could maybe get pointed in the right direction for where to start digging in!

The support was intentionally not added as this package also support writing schema files and I do not want to complicate .gqlconfig structure.

@DogsForArms
Copy link

Was there ever support added for this? I think it would be extremely nice to have.

@ndonnellan
Copy link

I don't know what graphql version the previous comments were referring to, but the proper command for at least [email protected] is:

import { printSchema, buildClientSchema } from 'graphql';
const introspectionQueryJSON = //getitfromsomewhere...
const schema = printSchema(buildClientSchema(introspectionQueryJSON));
// not introspectionQueryJSON.__schema

// write schema to schema.graphql and use it

the __schema property is accessed from within buildClientSchema.

@Mayank1791989
Copy link
Owner

@ndonnellan Thanks, I have fixed the comment.

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

4 participants