DEV Community

Michael Oshosanya
Michael Oshosanya

Posted on

Export graphql schema to postman or insomnia collections

I happened to have been assigned to work on a GraphQL project and I needed to make requests to the GraphQL server. The options were GraphQL playground and Altair GraphQL client which I seemed not to like for reasons I cannot particularly articulate so I decided to fall back on Insomnia or Postman which I am more familiar with. However, the support for GraphQL on those clients were not so good as they couldn't retrieve all the mutation and query schemas from the server, it's otherwise called schema introspection.

So I set out to build a tool that could get the schema and transform them into Postman and Insomnia collections, I also decided to use typescript as I wanted to learn it at that point and this was the available project.

The project lives at here on github

To use the tool;

yarn global add graphql-export

// For postman exports
graphql-export -u http://my-graph-ql-server-root -f postman

//For insomnia exports
graphql-export -u http://my-graph-ql-server-root -f insomnia

This creates a json file in the directory where you run the tool which you can import into Postman or Insomnia as the case may be.

Pull requests, code reviews and suggestions are all welcome.

Top comments (1)

Collapse
 
bernhardwebstudio profile image
Bernhard Webstudio

A very useful tool indeed!