How to Execute GraphQL Queries in Postman
We can execute GraphQL queries in Postman by writing the queries in the request body, selecting the HTTP verb as POST, and changing the body type of the HTTP request to GraphQL.
In the below Query examples, we will use the below GraphQL endpoint in the Postman URL –
https://countries.trevorblades.com/graphql
Example: In this example, we will query the country list, and fetch a country with code “BR”.
query {
country(code: "BR") {
name
currency
languages {
code
name
}
}
}
Output:
The output of the above postman call will look like below
What is GraphQL Queries
GraphQL is a powerful open-source Query Language for APIs. It is most commonly known for its single endpoint query which allows the user to define a single endpoint to fetch all the information needed.
Queries in GraphQL allow us to retrieve the data from an API endpoint, and the data is what we specify in the query itself. In this article, we will learn about GraphQL Queries, and we will create some ourselves.