GraphQL is a query language for APIs. GraphQL APIs have been widely adopted by developers because of some of the benefits they offer over RESTful APIs. One of the biggest benefits is that GraphQL allows for smarter and more precise querying which is especially useful when working with large APIs that return a lot of data. GraphQL enables users to specify exactly what data they get back in their response – nothing more, and nothing less; and it allows querying for multiple fields in a single request.
GraphQL vs REST
For example, if you want to use the Spotify REST API to get a list of all of the titles of all of the tracks of all of the albums by a particular artist, you would need to make multiple requests – one to find the artist ID, another to find all of the albums, and another to find all of the tracks on each album. If you were using the Spotify GraphQL API, you could access all of that data with a single query.
GraphQL in Postman
Postman v7.2, supports sending GraphQL queries in the request body, GraphQL variables, and GraphQL query autocompletion. Additionally, GraphQL support paired with our recent release of schema support and building APIs directly in Postman means users can now create and store GraphQL schemas directly in Postman itself.
Get Started Working with GraphQL in Postman
Here’s how to get started sending GraphQL queries in Postman:
Make sure you’ve selected POST as your HTTP method (if your API only supports request body for POST methods) and enter your endpoint. Since Postman’s GraphQL support has the GraphQL queries in the body of the request, you’ll need to use an HTTP method for which your API supports data in the request body. For Spotify, that means we need to use a POST method. – I used: