From 13f5c5dfe2b42327acc74873aaf6a4025b692e31 Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Tue, 14 Feb 2017 11:10:50 +0100 Subject: [PATCH] Relay promise compatibility --- .../ConfigExpressionProvider.php | 6 +- Relay/Connection/Output/ConnectionBuilder.php | 44 +++++++ Relay/Mutation/MutationFieldDefinition.php | 2 +- Relay/Mutation/MutationFieldResolver.php | 21 +++- Relay/Node/NodeFieldDefinition.php | 2 +- Relay/Node/NodeFieldResolver.php | 4 +- .../PluralIdentifyingRootFieldDefinition.php | 2 +- .../PluralIdentifyingRootFieldResolver.php | 18 ++- Resources/config/graphql_resolvers.yml | 4 + .../Relay/Mutation/MutationTest.php | 40 +++++++ .../app/Mutation/SimplePromiseMutation.php | 32 +++++ .../config/mutation/mapping/Inputs.types.yml | 5 + .../mutation/mapping/Payloads.types.yml | 6 + .../mutation/mapping/RootMutation.types.yml | 6 + .../app/config/mutation/services.yml | 9 +- .../Output/AbstractConnectionBuilderTest.php | 44 +++++++ .../ConnectionBuilderFromPromisedTest.php | 111 ++++++++++++++++++ .../Output/ConnectionBuilderTest.php | 28 +---- Tests/Relay/Node/NodeFieldDefinitionTest.php | 2 +- ...uralIdentifyingRootFieldDefinitionTest.php | 2 +- 20 files changed, 343 insertions(+), 45 deletions(-) create mode 100644 Tests/Functional/app/Mutation/SimplePromiseMutation.php create mode 100644 Tests/Relay/Connection/Output/AbstractConnectionBuilderTest.php create mode 100644 Tests/Relay/Connection/Output/ConnectionBuilderFromPromisedTest.php diff --git a/ExpressionLanguage/ConfigExpressionProvider.php b/ExpressionLanguage/ConfigExpressionProvider.php index 8c0bcf6d6..9153e6026 100644 --- a/ExpressionLanguage/ConfigExpressionProvider.php +++ b/ExpressionLanguage/ConfigExpressionProvider.php @@ -50,7 +50,7 @@ function ($alias, $args = '[]') { new ExpressionFunction( 'mutateAndGetPayloadCallback', function ($mutateAndGetPayload) { - $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $info) { '; + $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $context, $info) { '; $code .= 'return '.$mutateAndGetPayload.'; }'; return $code; @@ -60,7 +60,7 @@ function ($mutateAndGetPayload) { new ExpressionFunction( 'idFetcherCallback', function ($idFetcher) { - $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $info) { '; + $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $context, $info) { '; $code .= 'return '.$idFetcher.'; }'; return $code; @@ -70,7 +70,7 @@ function ($idFetcher) { new ExpressionFunction( 'resolveSingleInputCallback', function ($resolveSingleInput) { - $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $info) { '; + $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $context, $info) { '; $code .= 'return '.$resolveSingleInput.'; }'; return $code; diff --git a/Relay/Connection/Output/ConnectionBuilder.php b/Relay/Connection/Output/ConnectionBuilder.php index a651c9460..5fb93b5f9 100644 --- a/Relay/Connection/Output/ConnectionBuilder.php +++ b/Relay/Connection/Output/ConnectionBuilder.php @@ -44,6 +44,24 @@ public static function connectionFromArray($data, $args = []) ); } + /** + * A version of `connectionFromArray` that takes a promised array, and returns a + * promised connection. + * + * @param mixed $dataPromise a promise + * @param array|Argument $args + * + * @return mixed a promise + */ + public static function connectionFromPromisedArray($dataPromise, $args = []) + { + self::checkPromise($dataPromise); + + return $dataPromise->then(function ($data) use ($args) { + return static::connectionFromArray($data, $args); + }); + } + /** * Given a slice (subset) of an array, returns a connection object for use in * GraphQL. @@ -139,6 +157,25 @@ public static function connectionFromArraySlice($arraySlice, $args, array $meta) ); } + /** + * A version of `connectionFromArraySlice` that takes a promised array slice, + * and returns a promised connection. + * + * @param mixed $dataPromise a promise + * @param array|Argument $args + * @param array $meta + * + * @return mixed a promise + */ + public static function connectionFromPromisedArraySlice($dataPromise, $args, array $meta) + { + self::checkPromise($dataPromise); + + return $dataPromise->then(function ($arraySlice) use ($args, $meta) { + return static::connectionFromArraySlice($arraySlice, $args, $meta); + }); + } + /** * Return the cursor associated with an object in an array. * @@ -216,4 +253,11 @@ private static function getOptionsWithDefaults(array $options, array $defaults) { return $options + $defaults; } + + private static function checkPromise($value) + { + if (!is_callable([$value, 'then'])) { + throw new \InvalidArgumentException('This is not a valid promise.'); + } + } } diff --git a/Relay/Mutation/MutationFieldDefinition.php b/Relay/Mutation/MutationFieldDefinition.php index 473180abb..3d7730949 100644 --- a/Relay/Mutation/MutationFieldDefinition.php +++ b/Relay/Mutation/MutationFieldDefinition.php @@ -30,7 +30,7 @@ public function toMappingDefinition(array $config) 'args' => [ 'input' => ['type' => $inputType], ], - 'resolve' => "@=resolver('relay_mutation_field', [args, mutateAndGetPayloadCallback($mutateAndGetPayload)])", + 'resolve' => "@=resolver('relay_mutation_field', [args, context, info, mutateAndGetPayloadCallback($mutateAndGetPayload)])", ]; } diff --git a/Relay/Mutation/MutationFieldResolver.php b/Relay/Mutation/MutationFieldResolver.php index 3120e8123..a3cf78e49 100644 --- a/Relay/Mutation/MutationFieldResolver.php +++ b/Relay/Mutation/MutationFieldResolver.php @@ -11,18 +11,31 @@ namespace Overblog\GraphQLBundle\Relay\Mutation; +use GraphQL\Executor\Promise\PromiseAdapter; use Overblog\GraphQLBundle\Definition\Argument; use Overblog\GraphQLBundle\Resolver\Resolver; class MutationFieldResolver { - public function resolve($args, \Closure $mutateAndGetPayloadCallback) + /** + * @var PromiseAdapter + */ + private $promiseAdapter; + + public function __construct(PromiseAdapter $promiseAdapter) + { + $this->promiseAdapter = $promiseAdapter; + } + + public function resolve($args, $context, $info, \Closure $mutateAndGetPayloadCallback) { $input = new Argument($args['input']); - $payload = $mutateAndGetPayloadCallback($input); - Resolver::setObjectOrArrayValue($payload, 'clientMutationId', $input['clientMutationId']); + return $this->promiseAdapter->createFulfilled($mutateAndGetPayloadCallback($input, $context, $info)) + ->then(function ($payload) use ($input) { + Resolver::setObjectOrArrayValue($payload, 'clientMutationId', $input['clientMutationId']); - return $payload; + return $payload; + }); } } diff --git a/Relay/Node/NodeFieldDefinition.php b/Relay/Node/NodeFieldDefinition.php index 04f7a8f24..e6eeb80c5 100644 --- a/Relay/Node/NodeFieldDefinition.php +++ b/Relay/Node/NodeFieldDefinition.php @@ -30,7 +30,7 @@ public function toMappingDefinition(array $config) 'args' => [ 'id' => ['type' => 'ID!', 'description' => 'The ID of an object'], ], - 'resolve' => "@=resolver('relay_node_field', [args, idFetcherCallback($idFetcher)])", + 'resolve' => "@=resolver('relay_node_field', [args, context, info, idFetcherCallback($idFetcher)])", ]; } diff --git a/Relay/Node/NodeFieldResolver.php b/Relay/Node/NodeFieldResolver.php index 112445ba2..6bb70041f 100644 --- a/Relay/Node/NodeFieldResolver.php +++ b/Relay/Node/NodeFieldResolver.php @@ -13,8 +13,8 @@ class NodeFieldResolver { - public function resolve($args, \Closure $idFetcherCallback) + public function resolve($args, $context, $info, \Closure $idFetcherCallback) { - return $idFetcherCallback($args['id']); + return $idFetcherCallback($args['id'], $context, $info); } } diff --git a/Relay/Node/PluralIdentifyingRootFieldDefinition.php b/Relay/Node/PluralIdentifyingRootFieldDefinition.php index 1c74923c8..8581425e2 100644 --- a/Relay/Node/PluralIdentifyingRootFieldDefinition.php +++ b/Relay/Node/PluralIdentifyingRootFieldDefinition.php @@ -39,7 +39,7 @@ public function toMappingDefinition(array $config) 'type' => "[${config['outputType']}]", 'args' => [$argName => ['type' => "[${config['inputType']}!]!"]], 'resolve' => sprintf( - "@=resolver('relay_plural_identifying_field', [args['$argName'], resolveSingleInputCallback(%s)])", + "@=resolver('relay_plural_identifying_field', [args['$argName'], context, info, resolveSingleInputCallback(%s)])", $this->cleanResolveSingleInput($config['resolveSingleInput']) ), ]; diff --git a/Relay/Node/PluralIdentifyingRootFieldResolver.php b/Relay/Node/PluralIdentifyingRootFieldResolver.php index 069a7f345..bd6be71e3 100644 --- a/Relay/Node/PluralIdentifyingRootFieldResolver.php +++ b/Relay/Node/PluralIdentifyingRootFieldResolver.php @@ -11,16 +11,28 @@ namespace Overblog\GraphQLBundle\Relay\Node; +use GraphQL\Executor\Promise\PromiseAdapter; + class PluralIdentifyingRootFieldResolver { - public function resolve(array $inputs, callable $resolveSingleInput) + /** + * @var PromiseAdapter + */ + private $promiseAdapter; + + public function __construct(PromiseAdapter $promiseAdapter) + { + $this->promiseAdapter = $promiseAdapter; + } + + public function resolve(array $inputs, $context, $info, callable $resolveSingleInput) { $data = []; foreach ($inputs as $input) { - $data[$input] = call_user_func_array($resolveSingleInput, [$input]); + $data[$input] = $this->promiseAdapter->createFulfilled(call_user_func_array($resolveSingleInput, [$input, $context, $info])); } - return $data; + return $this->promiseAdapter->all($data); } } diff --git a/Resources/config/graphql_resolvers.yml b/Resources/config/graphql_resolvers.yml index f13cdc5d2..b4f3f4415 100644 --- a/Resources/config/graphql_resolvers.yml +++ b/Resources/config/graphql_resolvers.yml @@ -1,6 +1,8 @@ services: overblog_graphql.resolver.relay_mutation_field: class: Overblog\GraphQLBundle\Relay\Mutation\MutationFieldResolver + arguments: + - "@overblog_graphql.promise_adapter" tags: - { name: overblog_graphql.resolver, alias: "relay_mutation_field", method: "resolve" } @@ -16,5 +18,7 @@ services: overblog_graphql.resolver.relay_plural_identifying_field: class: Overblog\GraphQLBundle\Relay\Node\PluralIdentifyingRootFieldResolver + arguments: + - "@overblog_graphql.promise_adapter" tags: - { name: overblog_graphql.resolver, alias: "relay_plural_identifying_field", method: "resolve" } diff --git a/Tests/Functional/Relay/Mutation/MutationTest.php b/Tests/Functional/Relay/Mutation/MutationTest.php index f1909f694..28a01b419 100644 --- a/Tests/Functional/Relay/Mutation/MutationTest.php +++ b/Tests/Functional/Relay/Mutation/MutationTest.php @@ -86,6 +86,26 @@ public function testSupportsThunksAsInputAndOutputFields() $this->assertGraphQL($query, $expectedData); } + public function testSupportsPromiseMutations() + { + $query = <<<'EOF' +mutation M { + simplePromiseMutation(input: {clientMutationId: "abc"}) { + result + clientMutationId + } +} +EOF; + $expectedData = [ + 'simplePromiseMutation' => [ + 'result' => 1, + 'clientMutationId' => 'abc', + ], + ]; + + $this->assertGraphQL($query, $expectedData); + } + public function testContainsCorrectInput() { $query = <<<'EOF' @@ -240,6 +260,26 @@ public function testContainsCorrectField() 'kind' => 'OBJECT', ], ], + [ + 'name' => 'simplePromiseMutation', + 'args' => [ + [ + 'name' => 'input', + 'type' => [ + 'name' => null, + 'kind' => 'NON_NULL', + 'ofType' => [ + 'name' => 'simplePromiseMutationInput', + 'kind' => 'INPUT_OBJECT', + ], + ], + ], + ], + 'type' => [ + 'name' => 'simplePromiseMutationPayload', + 'kind' => 'OBJECT', + ], + ], ], ], ], diff --git a/Tests/Functional/app/Mutation/SimplePromiseMutation.php b/Tests/Functional/app/Mutation/SimplePromiseMutation.php new file mode 100644 index 000000000..9c9c0d32d --- /dev/null +++ b/Tests/Functional/app/Mutation/SimplePromiseMutation.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Overblog\GraphQLBundle\Tests\Functional\app\Mutation; + +use GraphQL\Executor\Promise\PromiseAdapter; + +class SimplePromiseMutation +{ + /** + * @var PromiseAdapter + */ + private $promiseAdapter; + + public function __construct(PromiseAdapter $promiseAdapter) + { + $this->promiseAdapter = $promiseAdapter; + } + + public function mutate() + { + return $this->promiseAdapter->createFulfilled(['result' => 1]); + } +} diff --git a/Tests/Functional/app/config/mutation/mapping/Inputs.types.yml b/Tests/Functional/app/config/mutation/mapping/Inputs.types.yml index bb6a599c0..8a660baa1 100644 --- a/Tests/Functional/app/config/mutation/mapping/Inputs.types.yml +++ b/Tests/Functional/app/config/mutation/mapping/Inputs.types.yml @@ -8,3 +8,8 @@ simpleMutationWithThunkFieldsInput: config: fields: inputData : { type: "Int" } + +simplePromiseMutationInput: + type: relay-mutation-input + config: + fields: [] diff --git a/Tests/Functional/app/config/mutation/mapping/Payloads.types.yml b/Tests/Functional/app/config/mutation/mapping/Payloads.types.yml index a3e9dc375..02b61a1b3 100644 --- a/Tests/Functional/app/config/mutation/mapping/Payloads.types.yml +++ b/Tests/Functional/app/config/mutation/mapping/Payloads.types.yml @@ -9,3 +9,9 @@ simpleMutationWithThunkFieldsPayload: config: fields: result: { type: "Int" } + +simplePromiseMutationPayload: + type: relay-mutation-payload + config: + fields: + result: { type: "Int" } diff --git a/Tests/Functional/app/config/mutation/mapping/RootMutation.types.yml b/Tests/Functional/app/config/mutation/mapping/RootMutation.types.yml index 230055886..12cd89778 100644 --- a/Tests/Functional/app/config/mutation/mapping/RootMutation.types.yml +++ b/Tests/Functional/app/config/mutation/mapping/RootMutation.types.yml @@ -14,3 +14,9 @@ RootMutation: inputType: simpleMutationWithThunkFieldsInput payloadType: simpleMutationWithThunkFieldsPayload mutateAndGetPayload: "@=mutation('simple_mutation_with_thunk_fields', [value])" + simplePromiseMutation: + builder: "Relay::Mutation" + builderConfig: + inputType: simplePromiseMutationInput + payloadType: simplePromiseMutationPayload + mutateAndGetPayload: "@=mutation('simple_promise_mutation')" diff --git a/Tests/Functional/app/config/mutation/services.yml b/Tests/Functional/app/config/mutation/services.yml index ff3842eda..e22701429 100644 --- a/Tests/Functional/app/config/mutation/services.yml +++ b/Tests/Functional/app/config/mutation/services.yml @@ -1,5 +1,12 @@ services: - overblog_graphql.test.mutation: + overblog_graphql.test.simple_mutation_with_thunk_fields: class: Overblog\GraphQLBundle\Tests\Functional\app\Mutation\SimpleMutationWithThunkFieldsMutation tags: - { name: "overblog_graphql.mutation", alias: "simple_mutation_with_thunk_fields", method: "mutate" } + + overblog_graphql.test.simple_promise_mutation: + class: Overblog\GraphQLBundle\Tests\Functional\app\Mutation\SimplePromiseMutation + arguments: + - "@overblog_graphql.react.promise_adapter" + tags: + - { name: "overblog_graphql.mutation", alias: "simple_promise_mutation", method: "mutate" } diff --git a/Tests/Relay/Connection/Output/AbstractConnectionBuilderTest.php b/Tests/Relay/Connection/Output/AbstractConnectionBuilderTest.php new file mode 100644 index 000000000..9fa88d0be --- /dev/null +++ b/Tests/Relay/Connection/Output/AbstractConnectionBuilderTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Overblog\GraphQLBundle\Tests\Relay\Connection\Output; + +use Overblog\GraphQLBundle\Relay\Connection\Output\Connection; +use Overblog\GraphQLBundle\Relay\Connection\Output\Edge; +use Overblog\GraphQLBundle\Relay\Connection\Output\PageInfo; + +abstract class AbstractConnectionBuilderTest extends \PHPUnit_Framework_TestCase +{ + protected $letters = ['A', 'B', 'C', 'D', 'E']; + + protected function getExpectedConnection(array $wantedEdges, $hasPreviousPage, $hasNextPage) + { + $edges = [ + 'A' => new Edge('YXJyYXljb25uZWN0aW9uOjA=', 'A'), + 'B' => new Edge('YXJyYXljb25uZWN0aW9uOjE=', 'B'), + 'C' => new Edge('YXJyYXljb25uZWN0aW9uOjI=', 'C'), + 'D' => new Edge('YXJyYXljb25uZWN0aW9uOjM=', 'D'), + 'E' => new Edge('YXJyYXljb25uZWN0aW9uOjQ=', 'E'), + ]; + + $expectedEdges = array_values(array_intersect_key($edges, array_flip($wantedEdges))); + + return new Connection( + $expectedEdges, + new PageInfo( + isset($expectedEdges[0]) ? $expectedEdges[0]->cursor : null, + end($expectedEdges) ? end($expectedEdges)->cursor : null, + $hasPreviousPage, + $hasNextPage + ) + ); + } +} diff --git a/Tests/Relay/Connection/Output/ConnectionBuilderFromPromisedTest.php b/Tests/Relay/Connection/Output/ConnectionBuilderFromPromisedTest.php new file mode 100644 index 000000000..f1e6f9814 --- /dev/null +++ b/Tests/Relay/Connection/Output/ConnectionBuilderFromPromisedTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Overblog\GraphQLBundle\Tests\Relay\Connection\Output; + +use Overblog\GraphQLBundle\Relay\Connection\Output\ConnectionBuilder; +use React\Promise\FulfilledPromise; + +class ConnectionBuilderFromPromisedTest extends AbstractConnectionBuilderTest +{ + public function testReturnsAllElementsWithoutFilters() + { + $promise = ConnectionBuilder::connectionFromPromisedArray($this->promisedLetters(), []); + $expected = $this->getExpectedConnection($this->letters, false, false); + $this->assertEqualsFromPromised($expected, $promise); + } + + public function testRespectsASmallerFirst() + { + $promise = ConnectionBuilder::connectionFromPromisedArray($this->promisedLetters(), ['first' => 2]); + $expected = $this->getExpectedConnection(['A', 'B'], false, true); + $this->assertEqualsFromPromised($expected, $promise); + } + + /** + * @param $invalidPromise + * @dataProvider invalidPromiseDataProvider + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage This is not a valid promise. + */ + public function testInvalidPromise($invalidPromise) + { + ConnectionBuilder::connectionFromPromisedArray($invalidPromise, []); + } + + public function invalidPromiseDataProvider() + { + return [ + [new \stdClass()], + ['fake'], + [['fake']], + [false], + [true], + ]; + } + + public function testRespectsASmallerFirstWhenSlicing() + { + $promise = ConnectionBuilder::connectionFromPromisedArraySlice( + $this->promisedLetters(['A', 'B', 'C']), + ['first' => 2], + [ + 'sliceStart' => 0, + 'arrayLength' => 5, + ] + ); + $expected = $this->getExpectedConnection(['A', 'B'], false, true); + $this->assertEqualsFromPromised($expected, $promise); + } + + /** + * @param $invalidPromise + * @dataProvider invalidPromiseDataProvider + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage This is not a valid promise. + */ + public function testInvalidPromiseWhenSlicing($invalidPromise) + { + ConnectionBuilder::connectionFromPromisedArraySlice($invalidPromise, [], []); + } + + private function promisedLetters(array $letters = null) + { + return \React\Promise\resolve($letters ?: $this->letters); + } + + private function assertEqualsFromPromised($expected, FulfilledPromise $promise) + { + $this->assertEquals($expected, self::await($promise)); + } + + private static function await(FulfilledPromise $promise) + { + $resolvedValue = null; + $rejectedReason = null; + $promise->then( + function ($value) use (&$resolvedValue) { + $resolvedValue = $value; + }, + function ($reason) use (&$rejectedReason) { + $rejectedReason = $reason; + } + ); + + if ($rejectedReason instanceof \Exception) { + throw $rejectedReason; + } + + return $resolvedValue; + } +} diff --git a/Tests/Relay/Connection/Output/ConnectionBuilderTest.php b/Tests/Relay/Connection/Output/ConnectionBuilderTest.php index 0c47486f5..357bebec3 100644 --- a/Tests/Relay/Connection/Output/ConnectionBuilderTest.php +++ b/Tests/Relay/Connection/Output/ConnectionBuilderTest.php @@ -13,7 +13,6 @@ use Overblog\GraphQLBundle\Relay\Connection\Output\Connection; use Overblog\GraphQLBundle\Relay\Connection\Output\ConnectionBuilder; -use Overblog\GraphQLBundle\Relay\Connection\Output\Edge; use Overblog\GraphQLBundle\Relay\Connection\Output\PageInfo; /** @@ -21,10 +20,8 @@ * * @see https://github.com/graphql/graphql-relay-js/blob/master/src/connection/__tests__/arrayconnection.js */ -class ConnectionBuilderTest extends \PHPUnit_Framework_TestCase +class ConnectionBuilderTest extends AbstractConnectionBuilderTest { - private $letters = ['A', 'B', 'C', 'D', 'E']; - public function testBasicSlicing() { $actual = ConnectionBuilder::connectionFromArray($this->letters); @@ -391,27 +388,4 @@ public function testReturnsAnEdgesCursorGivenAnArrayAndANonMemberObject() $this->assertNull($letterCursor); } - - private function getExpectedConnection(array $wantedEdges, $hasPreviousPage, $hasNextPage) - { - $edges = [ - 'A' => new Edge('YXJyYXljb25uZWN0aW9uOjA=', 'A'), - 'B' => new Edge('YXJyYXljb25uZWN0aW9uOjE=', 'B'), - 'C' => new Edge('YXJyYXljb25uZWN0aW9uOjI=', 'C'), - 'D' => new Edge('YXJyYXljb25uZWN0aW9uOjM=', 'D'), - 'E' => new Edge('YXJyYXljb25uZWN0aW9uOjQ=', 'E'), - ]; - - $expectedEdges = array_values(array_intersect_key($edges, array_flip($wantedEdges))); - - return new Connection( - $expectedEdges, - new PageInfo( - isset($expectedEdges[0]) ? $expectedEdges[0]->cursor : null, - end($expectedEdges) ? end($expectedEdges)->cursor : null, - $hasPreviousPage, - $hasNextPage - ) - ); - } } diff --git a/Tests/Relay/Node/NodeFieldDefinitionTest.php b/Tests/Relay/Node/NodeFieldDefinitionTest.php index f0001526b..d98433ff7 100644 --- a/Tests/Relay/Node/NodeFieldDefinitionTest.php +++ b/Tests/Relay/Node/NodeFieldDefinitionTest.php @@ -62,7 +62,7 @@ public function testValidConfig($idFetcher, $idFetcherCallbackArg, $nodeInterfac 'description' => 'Fetches an object given its ID', 'type' => $nodeInterfaceType, 'args' => ['id' => ['type' => 'ID!', 'description' => 'The ID of an object']], - 'resolve' => '@=resolver(\'relay_node_field\', [args, idFetcherCallback('.$idFetcherCallbackArg.')])', + 'resolve' => '@=resolver(\'relay_node_field\', [args, context, info, idFetcherCallback('.$idFetcherCallbackArg.')])', ]; $this->assertEquals($expected, $this->definition->toMappingDefinition($config)); diff --git a/Tests/Relay/Node/PluralIdentifyingRootFieldDefinitionTest.php b/Tests/Relay/Node/PluralIdentifyingRootFieldDefinitionTest.php index ad4c8f250..6d29559df 100644 --- a/Tests/Relay/Node/PluralIdentifyingRootFieldDefinitionTest.php +++ b/Tests/Relay/Node/PluralIdentifyingRootFieldDefinitionTest.php @@ -106,7 +106,7 @@ public function testValidConfig($resolveSingleInput, $expectedResolveSingleInput $expected = [ 'type' => '[User]', 'args' => ['username' => ['type' => '[UserInput!]!']], - 'resolve' => '@=resolver(\'relay_plural_identifying_field\', [args[\'username\'], resolveSingleInputCallback('.$expectedResolveSingleInputCallbackArg.')])', + 'resolve' => '@=resolver(\'relay_plural_identifying_field\', [args[\'username\'], context, info, resolveSingleInputCallback('.$expectedResolveSingleInputCallbackArg.')])', ]; $this->assertEquals($expected, $this->definition->toMappingDefinition($config));