Create a GraphQL API Schema for Query Auto-Completion
Our next topic in the "Querying with GraphQL in Postman" series is Creating API Schema. Here, we will learn to create a GraphQL API Schema for Query Auto-Completion.
A GraphQL schema describes the data users of GraphQL APIs can request. Also, it describes the mutation and queries that the client can use to read and publish data to the GraphQL server. In other words, your GraphQL schema must specify your client's or application's UI data requirements.
One of the most common features of Postman's GraphQL support is query auto-completion. The Postman API schemas are what power the auto-completion of queries. To develop a Postman GraphQL API schema:
⭐ In Postman, Go to the API Tab
⭐ Click on +New API
⭐ Give a name to your API
⭐ Ensure that you are in the Define Tab
⭐ From the dropdown menu, select GraphQL as your spec
⭐ Save after adding the Schema
⭐ Go back to the Collection Tab
⭐ From the dropdown menu, attach your Schema
⭐ When you start typing, query auto-completion should function
⭐ Finally, you will see your GraphQL Response.
GraphQL vs. Rest
Now, we will discuss the difference between GraphQL and Rest API in the "Querying with GraphQL in Postman" series.


Test GraphQL using Postman🧪🧑🔬
The last topic is Test GraphQL using Postman in the "Querying with GraphQL in Postman" series.
There are mainly two options to test a GraphQL API.
- Apollo Explorer/ Apollo Studio
- Postman
In this article, we will understand the second one, i.e., Postman. Any HTTP endpoint, including GraphQL, can be tested using this ideal tool.
Prerequisites📜
⚡ Installed the latest version of Git
⚡ NPM and node.js installed (version <8)
⚡ Postman Account or Postman agent installed
Clone, install, and start the server🤖
Paste the below code to pull the code from GitHub and start the server:
git clone https://github.com/apollographql/apollo-server-starter
cd apollo-server-starter
npm install && npm run start:example discography
Congratulations! Your server is running if you see the below line:
🚀 Server ready at http://localhost:4000/
Review the Schema🤓
Before moving forward with this, first, let's check our Schema. The discography schema has definitions for albums, tracks, and artists. Also, two queries return either all albums or a particular album.
enum Genre {
Pop,
Rock,
Alternative
HipHop
}
type Track {
title: String!
number: Int!
}
type Artist {
name: String!
}
type Album {
title: String!
artist: Artist!
tracks: [Track!]!
genre: Genre!
}
type Query {
albums(genre: Genre): [Album!]!
album(title: String!): Album
}
Write a GraphQL query in Postman
We will start by selecting the option to write the query in Postman.
The next step is to write the URL of the request. In this session, this (http://localhost:4000/) will be our URL.

We can also change the methods to POST, PUT, DELETE, etc., by clicking on the dropdown arrow. We will change the method name from GET to POST as all GraphQL operations work on top of the HTTP POST method.

Select GraphQL from the list of options below the Body selection by clicking it. A Query window and a GraphQL Variables window will be displayed to you.

Now we have to write our code in the Query Section. You can also copy the code given below.
query GetAllAlbums {
albums {
title
artist {
name
}
tracks {
title
number
}
genre
}
}
Click on the Send button to generate the request. You will see the below page after clicking.

To apply sorting and filtering to our data so that we can view relevant data, we often need to build queries that return data and pass in variables. Use the below code in the Query Section.
query GetAllAlbums ($genre: Genre) {
albums (genre: $genre) {
title
artist {
name
}
tracks {
title
number
}
genre
}
}
The window should appear like this.

And after clicking on Send button, you will see the below screen.

Frequently Asked Questions 🤔
How do I set up an online GraphQL server?
Any environment that permits the deployment of "Node.js" projects is capable of hosting GraphQL servers created with apollo-server. To allow serverless deployment with AWS Lambda, apollo-server even offers versions.
There are guides for deployment available for:
👉 Heroku
👉 Lambda
👉 Azure Functions
Can I use GraphQL with REST API?
If you are a front-end developer team, who wants to sample GraphQL without requesting that the backend team create a GraphQL server, calling REST APIs from a GraphQL client unlocks the benefits of GraphQL for more individuals.
Which database is best for GraphQL?
There is a list of databases that can be used for GraphQL.
👉 LunaSec
👉 Back4App
👉 Weaviate
👉 ArangoDB
👉 FaunaDB
Conclusion🎉
We have discussed the topic of Querying with GraphQL in Postman. We have seen topics like GraphQL, creating a GraphQL API Schema, GraphQL vs. Res API, and Testing GraphQL using Postman.
We hope this blog has helped you enhance your knowledge of "Querying with GraphQL in Postman." If you want to learn more, check out our articles Purchasing and billing, Configuring SCIM in Postman, Postman to API Testing, and many more on our platform Coding Ninjas Studio. You can also check our blogs on:
- Web Testing
- API Testing
- API
But suppose you have just started your learning process and are looking for questions from tech giants like Amazon, Microsoft, Uber, etc. In that case, you must look at the problems, interview experiences, and interview bundle for placement preparations.
However, you may consider our paid courses to give your career an edge over others!
Happy Learning!