简体   繁体   中英

How to generate graphql query from endpoint

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?

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.

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM