15

I would like to build a script that generates an example query with all fields from a GraphQL endpoint.

I found some mechanisms to get the schema as a JSON structure and to adapt the schema files to a query. but nothing takes an endpoint and provides a suitable query for that endpoint.

Does someone have any experience in that?

2 Answers 2

17

Have same problems. The best approach that I know for now is to:

  1. generate schema.graphql from endpoint using get-graphql-schema : https://github.com/prisma/get-graphql-schema
  2. generate queries and mutations from schema.graphql using gql-generator : https://github.com/modelo/gql-generator

There was a tool that claimed to "generate queries from endpoint", but I wasn't able to make it working in my case, and now I can't even find it, but it was called "gql-test" and I still have it installed in npm.

Sign up to request clarification or add additional context in comments.

Comments

3

I just stumbled upon a chrome extension, Graphql Query Generator, look it up on chrome web store.

Its generates sample queries with dummy data direclty from schema files, helped me as I'm still getting hang of the GraphQL query syntax.

It seems to use some public domain code internally, but no credits whatsoever, not good :)

2 Comments

I tried this, but there are not sample queries.
@AaronMcMillin this tool will generate the queries and mutations if you supply a valid schema, tried that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.