---
title: "Query content using GraphQL"
slug: "query-content-using-graphql"
abstract: "How to query content using GraphQL."
---
# Query content using GraphQL

To verify that the setup was successful, let's create some test queries. Because the [new content you just added](https://doc.sitecore.com/ch-one/en/developers/content-hub-one/build-a-website-with-the-starter-kit/4-query-content/add-new-content-and-media-items.md "Add new content and media items") has not yet been published, you can use the [Preview API endpoint](https://doc.sitecore.com/ch-one/en/developers/content-hub-one/build-a-website-with-the-starter-kit/4-query-content/preview-and-delivery-apis.md "Preview and Delivery APIs").

```shell
https://content-api.sitecorecloud.io/api/content/v1/preview/graphql/
```

To query the content, you need to [authenticate](https://doc.sitecore.com/ch-one/en/developers/content-hub-one/build-a-website-with-the-starter-kit/4-query-content/preview-and-delivery-apis.md "Preview and Delivery APIs"). In the Integrated Development Environment (IDE), on the **HTTP HEADERS** tab, add the API key using the following format (replacing the example API key):

```shell
{
  "X-GQL-Token":"aEtSNzBsTaEtSNzBMA"
}
```

## Get all events and event details

This sample query gets all events, along with their details. This includes the event name, description, location, date, image, and agenda.

```json
query {
 allEvent {
  total
  results {
   id
   name
   eventName
   eventDescription
   eventLocation
   eventDate
   eventImage {
    results {
     fileName
    }
   }
   agenda {
    results {
     __typename
    }
   }
  }
 }
}
```

> [!note]
> Because the `eventImage` and `agenda` fields are returned as objects or lists of objects, you need to fetch the specific fields from these objects.

## Get information on the event, agenda, and speakers

The [content model](https://doc.sitecore.com/ch-one/en/developers/content-hub-one/build-a-website-with-the-starter-kit/4-query-content/content-model-for-events.md "Content model for events") for this tutorial includes information on the event, agenda, and speakers. The following query fetches this information.

```json
query {
  allEvent {
    total
    results {
      id
      name
      eventName
      eventDescription
      eventLocation
      eventDate
      eventImage {
        results {
          fileId
          fileName
        }
      }
      agenda {
        total
    results {
      __typename
     ... on Talk {
      id
      name
      talkTitle
      talkDescription
      image {
       results {
        fileId
        fileName
       }
      }
      duration
      time
      speaker {
       __typename
       results{
        ... on Speaker {
         id
         name
         speakerName
         speakerBio
         speakerImage {
          results {
           fileId
           fileName
          }
         }
        }
       }
      }
     }
        }
      }
  }
 }
}
```