Last updated 1 year ago
When testing a GraphQL endpoint, we set the $schema property on the test class.
$schema
The mutation must be stored in a variable for readability in each test.
To run the GraphQL endpoint, call the ->graphql() method.
->graphql()
/** * @var string the GraphQL schema name */ protected $schema = 'sandboxes';
public function sandboxes_save_object_returns_200(): void { $mutation = <<<'GQL' mutation { saveSandbox(data: { title: "New Sandbox" }) { id title } } GQL; // ... }
public function sandboxes_save_object_returns_200(): void { $mutation = <<<'GQL' mutation { saveSandbox(data: { title: "New Sandbox" }) { id title } } GQL; $this->actingAsAdmin() ->authenticate() ->graphql($mutation); }