documentation/getting-started/graphql/creating-a-query.mdx
Switch to the GraphQL platform on Hoppscotch and connect to the below GraphQL server.
https://echo.hoppscotch.io/graphql
Once a successful connection has been made, you can view both documentation and the schema using Hoppscotch.
It is important to explore the schema to understand the different queries, mutations, types, and subscriptions that are offered by the endpoint.
You can execute queries to retrieve data from the GraphQL server by following these steps:
query under Root Types to view the listed query fields.Let's explore a sample query using the Countries GraphQL API.
Open Hoppscotch, switch to the GraphQL client and connect to the endpoint below:
https://countries.trevorblades.com/graphql
Explore the schema and documentation to understand more about the endpoint.
Select the countries query, cherry-pick the fields, and add a filter to return results where the name field is equal to "Germany".
{
countries (filter: {name: {eq: "Germany"}}) {
name
code
capital
emoji
currencies
}
}
Click on the run button to execute the query.
The query will return the following response.
{
"data": {
"countries": [
{
"name": "Germany",
"code": "DE",
"capital": "Berlin",
"emoji": "🇩🇪",
"currencies": [
"EUR"
]
}
]
}
}