private static function getOperationRootType(Schema $schema, OperationDefinitionNode $operation)
{
switch ($operation->operation) {
case 'query':
return $schema->getQueryType();
case 'mutation':
$mutationType = $schema->getMutationType();
if (!$mutationType) {
throw new Error('Schema is not configured for mutations', [$operation]);
}
return $mutationType;
case 'subscription':
$subscriptionType = $schema->getSubscriptionType();
if (!$subscriptionType) {
throw new Error('Schema is not configured for subscriptions', [$operation]);
}
return $subscriptionType;
default:
throw new Error('Can only execute queries, mutations and subscriptions', [$operation]);
}
}