GraphQL queries

To get back all collections and items in the collections, you can query like this:

query {
  collections {
    id 
    title
    items{
      id
      name
      price
    }
  }
}

To query back one collection with all the items, then you need to structure differently.

First you need to set a query variable:

{"id": "cjwuuj5bz000i0719rrtw5gqk"}

Then you update your query code like so (notice singular collection):

query($id: ID!) {
  collection(id: $id) {
    id 
    title
    items{
      id
      name
      price
    }
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *