Documentation
Feedback
Guides
Learning Center

Learning Center
Learning Center
GraphQL: Using GraphiQL
View in Portuguese
This content was migrated from the VTEX Learning Center and is no longer being actively maintained. For the most accurate and up-to-date information, please check the official documentation.

Introduction

Now, with the query and resolver implemented, we need to use it to retrieve the top n most viewed products. By using the GraphQL IDE, we can test the query we implemented before.

GraphiQL

GraphiQL is a graphical interactive in-browser GraphQL IDE. Before using the query in the app, it is interesting to test its functionality. To do so, we will reproduce your query usage in the GraphQL IDE.

Exploring the IDE interface, there are three main areas: the coding area, the query variables area and the debug area. Check where each shows up in the interface in the image 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"}}

Testing your query

  1. Open the GraphiQL route and type the code below in the coding area:


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

  2. The query that we just declared uses a variable (topN). Now we need to declare it in the Query Variables area:


    _10
    {
    _10
    "topN": 2
    _10
    }

    :exclamation: The Query Variables area is below the coding area, to amplify its area just drag by the title.

  3. At last, just click on the play button and check the outcome on the debug area. The query results should look like this:

    {"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"}}

On this page