# Use GraphQL API

Use GraphQL when a client needs selected fields from Cloud resources. Complete the [Cloud quickstart](/docs/cloud/getting-started/quickstart.md) first so `VERYFRONT_API_KEY` is available in your terminal.

## Query projects

The `projects` field returns a connection object. Select project fields inside its `data` field:

```graphql title="query.graphql"
query {
  projects(input: { limit: 5 }) {
    data {
      id
      slug
      name
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

Send the query as JSON to the GraphQL endpoint:

```bash title="Terminal"
curl --silent --show-error --fail-with-body \
  https://api.veryfront.com/graphql \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"query { projects(input: { limit: 5 }) { data { id slug name } pageInfo { hasNextPage endCursor } } }"}'
```

## Inspect data and errors

Read project records from `data.projects.data`. If `data.projects.pageInfo.hasNextPage` is true, pass `endCursor` as `input.cursor` in the next request.

Also check the top-level `errors` array. GraphQL can return errors alongside data, so an HTTP success status alone doesn't confirm the query succeeded.

A query such as `projects { id }` is invalid because `id` belongs to a project, not to the connection object. Use the [Projects operation reference](/docs/cloud/graphql/operations/projects/queries/projects.md) when checking the field signature.

## Next

* [GraphQL API](/docs/cloud/graphql.md): Explore queries and mutations.
* [Authentication](/docs/cloud/authentication.md): Check credentials and project access.
