From 82432e6562bae0c7987d67b4e0b693e93aeb08f4 Mon Sep 17 00:00:00 2001 From: lorado Date: Thu, 13 Dec 2018 16:31:31 +0100 Subject: [PATCH 1/4] fix tests - there were wrong assertions --- tests/GraphQLMutationTest.php | 4 +--- tests/GraphQLTest.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/GraphQLMutationTest.php b/tests/GraphQLMutationTest.php index f4e99a6..3a45a83 100644 --- a/tests/GraphQLMutationTest.php +++ b/tests/GraphQLMutationTest.php @@ -41,9 +41,7 @@ public function testMutation() { 'errors' => [ [ 'message' => 'validation', - 'extensions' => [ - 'category' => 'graphql', - ], + 'category' => 'graphql', 'validation' => [ 'name' => [ 'The name must be between 3 and 10 characters.' diff --git a/tests/GraphQLTest.php b/tests/GraphQLTest.php index ec1d538..7ea310e 100644 --- a/tests/GraphQLTest.php +++ b/tests/GraphQLTest.php @@ -178,9 +178,7 @@ public function testAuthorizeChecking() { 'errors' => [ [ 'message' => 'UNAUTHORIZED', - 'extensions' => [ - 'category' => 'graphql', - ], + 'category' => 'graphql', ] ], 'data' => [ From 8fd00b015bebe17caeb40d85d940a23be8e70e59 Mon Sep 17 00:00:00 2001 From: lorado Date: Thu, 13 Dec 2018 16:37:29 +0100 Subject: [PATCH 2/4] rename __typename to _morphType --- src/Support/Definition/Definition.php | 2 +- .../Eloquent/Relation/MorphToRelationTransformer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Support/Definition/Definition.php b/src/Support/Definition/Definition.php index 84553f5..0499416 100644 --- a/src/Support/Definition/Definition.php +++ b/src/Support/Definition/Definition.php @@ -118,7 +118,7 @@ public function resolveInputType() { 'fields' => function () { return array_merge([ 'id' => Type::id(), - '__typename' => Type::string(), + '_morphType' => Type::string(), ], $this->getMutable()); } ])); diff --git a/src/Support/Transformer/Eloquent/Relation/MorphToRelationTransformer.php b/src/Support/Transformer/Eloquent/Relation/MorphToRelationTransformer.php index f449d69..74be8f0 100644 --- a/src/Support/Transformer/Eloquent/Relation/MorphToRelationTransformer.php +++ b/src/Support/Transformer/Eloquent/Relation/MorphToRelationTransformer.php @@ -11,7 +11,7 @@ class MorphToRelationTransformer extends AbstractRelationTransformer { */ protected function hydrate() { $id = array_get($this->values, 'id', null); - $type = array_get($this->values, '__typename', null); + $type = array_get($this->values, '_morphType', null); if (is_null($type)) { throw new \Exception( From 6e86475e53c129677b1375984176a74798c030a9 Mon Sep 17 00:00:00 2001 From: lorado Date: Thu, 13 Dec 2018 16:38:39 +0100 Subject: [PATCH 3/4] fix code-style --- src/GraphQLController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/GraphQLController.php b/src/GraphQLController.php index 4a28a6c..7375c1b 100644 --- a/src/GraphQLController.php +++ b/src/GraphQLController.php @@ -22,7 +22,6 @@ class GraphQLController extends Controller { * @return \Illuminate\Http\JsonResponse */ public function query(Request $request, $schema = null) { - $inputs = $request->all(); $data = []; @@ -48,7 +47,6 @@ public function query(Request $request, $schema = null) { else { $data = $this->executeQuery($schema, $inputs); } - } catch (\Exception $exception) { $data = GraphQL::formatGraphQLException($exception); Log::debug($exception); From 726466d59b4906ded6301934401843bbefb5927f Mon Sep 17 00:00:00 2001 From: lorado Date: Thu, 13 Dec 2018 19:38:30 +0100 Subject: [PATCH 4/4] Revert "fix tests - there were wrong assertions" This reverts commit 82432e65 Sorry, my dependencies were not updated, so I got other output... My changes were wrong, so I reverted them --- tests/GraphQLMutationTest.php | 4 +++- tests/GraphQLTest.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/GraphQLMutationTest.php b/tests/GraphQLMutationTest.php index 3a45a83..f4e99a6 100644 --- a/tests/GraphQLMutationTest.php +++ b/tests/GraphQLMutationTest.php @@ -41,7 +41,9 @@ public function testMutation() { 'errors' => [ [ 'message' => 'validation', - 'category' => 'graphql', + 'extensions' => [ + 'category' => 'graphql', + ], 'validation' => [ 'name' => [ 'The name must be between 3 and 10 characters.' diff --git a/tests/GraphQLTest.php b/tests/GraphQLTest.php index 7ea310e..ec1d538 100644 --- a/tests/GraphQLTest.php +++ b/tests/GraphQLTest.php @@ -178,7 +178,9 @@ public function testAuthorizeChecking() { 'errors' => [ [ 'message' => 'UNAUTHORIZED', - 'category' => 'graphql', + 'extensions' => [ + 'category' => 'graphql', + ], ] ], 'data' => [