Documentation
Feedback
Guides
App Development

App Development
ServicesDeveloping services on VTEX IO
7. Using GraphiQL

Now that you've implemented the GraphQL query and its resolver, it's time to put it to the test using GraphiQL, an in-browser GraphQL IDE. Follow the steps below to efficiently experiment with your GraphQL queries.

Accessing the GraphiQL IDE

Navigate to the GraphQL route prompted in the terminal after linking your app. The GraphiQL interface consists of three main areas: the coding area, the query variables area, and the debug area, as illustrated below.

{"base64":"  ","img":{"width":2878,"height":1526,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":167843,"url":"https://user-images.githubusercontent.com/43679629/83764107-e900ea80-a64f-11ea-969f-116ea896fe2d.png"}}

Terminal

_10
17:31:10.803 -info: Build accepted for vtex.service-course-template@0.0.1 at myaccount/myworkspace vtex.builder-hub@0.250.0
_10
17:31:10.818 - info: Starting build for app vtex.service-course-template@0.0.1 vtex.builder-hub@0.250.0
_10
17:31:19.588 - warn: node builder overrode the following options in tsconfig.json: target: 'es2017' = 'es2019' vtex.builder-hub@0.250.0
_10
17:31:27.227 - info: Bundle: 26 files - 34.44MB vtex.builder-hub@0.250.0
_10
17:31:27.228 - info: Sent bundle to Apps in 3869ms vtex.builder-hub@0.250.0
_10
17:31:27.229 - info:App linked successfully vtex.builder-hub@0.250.0
_10
17:31:27.230 - info: You can try out the queries in this app using the GraphiQLIDE available at:
_10
https://myworkspace--myaccount.myvtex.com/_v/private/vtex.service-course-template@0.0.1/graphiql/v1 vtex.builder-hub@0.250.0

Writing the query

In the coding area, enter the GraphQL query provided in the right panel. This query is designed to retrieve information about the topN most viewed products, including their slug (product identifier) and count (number of views).

Terminal
Query

_10
query ($topN: Int) {
_10
productList(topN: $topN){
_10
slug
_10
count
_10
}
_10
}

Using query variables

Since the declared query involves a variable (topN), declare it in the Query Variables area located beneath the coding area. You can expand this area by dragging its title.

Terminal
Query
QueryVariables

_10
{
_10
"topN": 2
_10
}

Running the query

Click the Play button to execute the code, and check the outcome in the debug area.

{"base64":"  ","img":{"width":2338,"height":1386,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":150451,"url":"https://user-images.githubusercontent.com/43679629/83763622-4c3e4d00-a64f-11ea-9615-435811d411c6.png"}}

Terminal
Query
QueryVariables
Response

_14
{
_14
"data": {
_14
"productList": [
_14
{
_14
"slug": "1920",
_14
"count": 7
_14
},
_14
{
_14
"slug": "1234",
_14
"count": 5
_14
}
_14
]
_14
}
_14
}

Accessing the GraphiQL IDE

Navigate to the GraphQL route prompted in the terminal after linking your app. The GraphiQL interface consists of three main areas: the coding area, the query variables area, and the debug area, as illustrated below.

{"base64":"  ","img":{"width":2878,"height":1526,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":167843,"url":"https://user-images.githubusercontent.com/43679629/83764107-e900ea80-a64f-11ea-969f-116ea896fe2d.png"}}

Writing the query

In the coding area, enter the GraphQL query provided in the right panel. This query is designed to retrieve information about the topN most viewed products, including their slug (product identifier) and count (number of views).

Using query variables

Since the declared query involves a variable (topN), declare it in the Query Variables area located beneath the coding area. You can expand this area by dragging its title.

Running the query

Click the Play button to execute the code, and check the outcome in the debug area.

{"base64":"  ","img":{"width":2338,"height":1386,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":150451,"url":"https://user-images.githubusercontent.com/43679629/83763622-4c3e4d00-a64f-11ea-9615-435811d411c6.png"}}

Terminal

_10
17:31:10.803 -info: Build accepted for vtex.service-course-template@0.0.1 at myaccount/myworkspace vtex.builder-hub@0.250.0
_10
17:31:10.818 - info: Starting build for app vtex.service-course-template@0.0.1 vtex.builder-hub@0.250.0
_10
17:31:19.588 - warn: node builder overrode the following options in tsconfig.json: target: 'es2017' = 'es2019' vtex.builder-hub@0.250.0
_10
17:31:27.227 - info: Bundle: 26 files - 34.44MB vtex.builder-hub@0.250.0
_10
17:31:27.228 - info: Sent bundle to Apps in 3869ms vtex.builder-hub@0.250.0
_10
17:31:27.229 - info:App linked successfully vtex.builder-hub@0.250.0
_10
17:31:27.230 - info: You can try out the queries in this app using the GraphiQLIDE available at:
_10
https://myworkspace--myaccount.myvtex.com/_v/private/vtex.service-course-template@0.0.1/graphiql/v1 vtex.builder-hub@0.250.0

Contributors
1
Photo of the contributor
+ 1 contributors
Was this helpful?
Yes
No
Suggest edits (Github)
Contributors
1
Photo of the contributor
+ 1 contributors
On this page