> This page is for Developer.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bigcommerce.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bigcommerce.com/_mcp/server.

# Lab - Query Practice

Plan: Developer Foundations

Lesson 19 of 28 · 30 min

### In this lab, you will:

* Query for products within a specific price range
* Query for products with a specific search term and sort them
* Query for banner content

## Query for Products Within a Specific Price Range

In this query, we will use a filter to search for the first three products within a price range of $50 and $150.

1. In the GraphQL playground, **begin writing the query** with the `root`, `site`, `search` field, and `searchProducts` field.

```graphql showLineNumbers={false}
query{
  site{
    search{
      searchProducts{

      }
    }
  }
}
```

2. Next, let's add a filter to define the information we want. **Add** the `filters` field and **specify** that we're looking for the `price` with a `minPrice` of 50 and `maxPrice` of 150.

```graphql showLineNumbers={false}
query{
  site{
    search{
      searchProducts(
        filters:{
          price:{
            minPrice:50
            maxPrice:150
          }
        }
      )
    }
  }
}
```

3. Next, let's add the product information that we want. **Add** the `products` field and **specify** that we want the *first 3* products plus their `entityId`, `name`, and `price`.

```graphql showLineNumbers={false}
query{
  site{
    search{
      searchProducts(
        filters:{
          price:{
            minPrice:50
            maxPrice:150
          }
        }
      ){
        products(first:3){
          edges{
            node{
              entityId
              name
              prices{
                price{
                  value
                }
              }
            }
          }
        }
      }
    }
  }
}
```

4. **Click the Play button** in the middle of the GraphQL Playground to run the query.
5. **Observe** the response.

## Query for Products with a Specific Search Term and Sort Them

In this query, we will ask for the first five products with the word "Shirt" as a search term and then sort them alphabetically.

1. In the GraphQL playground, **begin writing the query** with the `root`, `site`, `search` field, and `searchProducts` field.

```graphql showLineNumbers={false}
query{
  site{
    search{
      searchProducts{

      }
    }
  }
}
```

2. Next, let's add a filter to define the information we want. **Add** the `filters` field and specify that we're looking for the `searchTerm: "shirt"`.

```graphql showLineNumbers={false}
query{
  site{
    search{
      searchProducts(
        filters:{
          searchTerm:"shirt"
        }
      )
    }
  }
}
```

3. Next, add another filter to sort the information we want. **Add** the `sort` field and **specify** that we want to sort the products from `A_TO_Z`.

```graphql showLineNumbers={false}
query{
  site{
    search{
      searchProducts(
        filters:{
          searchTerm:"shirt"
        }
        sort:A_TO_Z
      )
    }
  }
}
```

4. Lastly, we need to define what product information we want from the products. **Add** the `products` field\_ and **specify** that we want the *first 5*, `entityId`, `name`, and `price`.

```graphql showLineNumbers={false}
query{
  site{
    search{
      searchProducts(
        filters:{
          searchTerm:"Shirt"
        }
        sort:A_TO_Z
      ){
        products(first:5){
          edges{
            node{
              entityId
              name
              prices{
                price{
                  value
                }
              }
            }
          }
        }
      }
    }
  }
}
```

5. **Click the Play button** in the middle of the GraphQL Playground to run the query.
6. **Observe** the response.

## Query for Banner Content

In this query, we will ask to see the `entityId`, `name`, `content`, and `location` of a banner on the Home Page.

1. In the GraphQL playground, **begin writing the query** with the `root`, `site`, and `content` fields.

```graphql showLineNumbers={false}
query{
  site{
    content{

    }
  }
}
```

2. Next, let's specify the information we want. **Add** the `banners` field and specify that we're looking for the `entityId`, `name`, `content`, and `location`.

```graphql showLineNumbers={false}
query{
  site{
    content{
      banners{
        homePage{
          edges{
            node{
              entityId
              name
              content
              location
            }
          }
        }
      }
    }
  }
}
```

3. **Click the Play button** in the middle of the GraphQL Playground to run the query.
4. **Observe** the response.