Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon What is the difference between index and show queries in Runway


What is the difference between index and show queries in Runway


According to the Runway documentation, there are two main types of GraphQL queries you can perform with Runway:

1. Index Query:
- An index query is used to fetch a list of models.
- Example:

graphql
     {
       products {
         data {
           id
           name
           price
           description
         }
       }
     }
     

- Index queries also support pagination, filtering, and sorting, as described in the Statamic GraphQL documentation.

2. Show Query:
- A show query is used to fetch a single model by its ID.
- Example:

graphql
     {
       products(id: "2") {
         id
         name
         price
         description
       }
     }
     

- The `products(id: "2")` part of the query fetches the model with the ID of "2".

The main difference between the two is that the index query fetches a list of models, while the show query fetches a single model by its ID. The index query is useful for displaying collections of data, while the show query is useful for retrieving the details of a specific model.

Both types of queries support related models, filtering, sorting, and other advanced features provided by Statamic's GraphQL API and Runway's integration with it.

Citations:
[1] https://statamic.com/addons/rad-pack/runway
[2] https://runway.duncanmcclean.com/rest-api
[3] https://runway.duncanmcclean.com/graphql
[4] https://github.com/statamic/content-api-demo
[5] https://accreditly.io/articles/how-to-use-graphql-in-statamic