GraphQL\Executor\Executor::getOperationRootType PHP Method

getOperationRootType() private static method

Extracts the root type of the operation from the schema.
private static getOperationRootType ( Schema $schema, OperationDefinitionNode $operation ) : ObjectType
$schema GraphQL\Schema
$operation GraphQL\Language\AST\OperationDefinitionNode
return GraphQL\Type\Definition\ObjectType
    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]);
        }
    }