> For the complete documentation index, see [llms.txt](https://docs.elentra.org/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elentra.org/api/automated-testing/functional-tests/testing-http-verbs/graphql-requests.md).

# GraphQL Requests

#### GraphQL Requests

When testing a GraphQL endpoint, we set the `$schema` property on the test class.

```php
/**
 * @var string the GraphQL schema name
 */
protected $schema = 'sandboxes';
```

The mutation must be stored in a variable for readability in each test.

```php
public function sandboxes_save_object_returns_200(): void
{
    $mutation = <<<'GQL'
    mutation {
        saveSandbox(data: { title: "New Sandbox" }) {
            id
            title
        }
    }
    GQL;
    
    // ...
}
```

To run the GraphQL endpoint, call the `->graphql()` method.

```php
public function sandboxes_save_object_returns_200(): void
{
    $mutation = <<<'GQL'
    mutation {
        saveSandbox(data: { title: "New Sandbox" }) {
            id
            title
        }
    }
    GQL;

    $this->actingAsAdmin()
        ->authenticate()
      	->graphql($mutation);
}
```
