mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-21 20:36:05 +03:00
Added test case for extended schema resolvers
This commit is contained in:
parent
cd38568aaa
commit
1a1bf17c6a
@ -1927,4 +1927,39 @@ class SchemaExtenderTest extends TestCase
|
||||
self::assertEquals('Must provide only one mutation type in schema.', $error->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/webonyx/graphql-php/pull/381
|
||||
*/
|
||||
public function testOriginalResolversArePreserved()
|
||||
{
|
||||
$queryType = new ObjectType([
|
||||
'name' => 'Query',
|
||||
'fields' => [
|
||||
'hello' => [
|
||||
'type' => Type::string(),
|
||||
'resolve' => static function () {
|
||||
return 'Hello World!';
|
||||
},
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$schema = new Schema(['query' => $queryType]);
|
||||
|
||||
$documentNode = Parser::parse('
|
||||
extend type Query {
|
||||
misc: String
|
||||
}
|
||||
');
|
||||
|
||||
$extendedSchema = SchemaExtender::extend($schema, $documentNode);
|
||||
$helloResolveFn = $extendedSchema->getQueryType()->getField('hello')->resolveFn;
|
||||
|
||||
self::assertInternalType('callable', $helloResolveFn);
|
||||
|
||||
$query = '{ hello }';
|
||||
$result = GraphQL::executeQuery($extendedSchema, $query);
|
||||
self::assertSame(['data' => ['hello' => 'Hello World!']], $result->toArray());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user