public getMutationType ( ) : |
||
return |
/** * 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]); } }
public function testDefinesAMutationSchema() { $schema = new Schema($this->blogQuery, $this->blogMutation); $this->assertSame($this->blogMutation, $schema->getMutationType()); $writeMutation = $this->blogMutation->getField('writeArticle'); $this->assertInstanceOf('GraphQL\\Type\\Definition\\FieldDefinition', $writeMutation); $this->assertSame($this->blogArticle, $writeMutation->getType()); $this->assertSame('Article', $writeMutation->getType()->name); $this->assertSame('writeArticle', $writeMutation->name); }