protected static function getOperationRootType(Schema $schema, OperationDefinition $operation)
    {
        switch ($operation->get('operation')) {
            case 'query':
                return $schema->getQueryType();
            case 'mutation':
                $mutationType = $schema->getMutationType();
                if (!$mutationType) {
                    throw new \Exception('Schema is not configured for mutations.');
                }

                return $mutationType;
        }

        throw new \Exception('Can only execute queries and mutations.');
    }