GraphQL\Schema::getMutationType PHP Method

getMutationType() public method

public getMutationType ( ) : ObjectType
return GraphQL\Type\Definition\ObjectType
    public function getMutationType()
    {
        return $this->mutationType;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Extracts the root type of the operation from the schema.
  *
  * @param Schema $schema
  * @param OperationDefinitionNode $operation
  * @return ObjectType
  * @throws Error
  */
 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]);
     }
 }
All Usage Examples Of GraphQL\Schema::getMutationType