From 915f20f7e436b834a3dd3c43dc7a1c5c91af37ad Mon Sep 17 00:00:00 2001 From: Benedictus Arya Date: Thu, 7 Dec 2017 11:56:46 +0700 Subject: [PATCH 1/6] auto get field from interface --- src/Folklore/GraphQL/Support/Type.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Folklore/GraphQL/Support/Type.php b/src/Folklore/GraphQL/Support/Type.php index 20ba4e2e..54407a7a 100644 --- a/src/Folklore/GraphQL/Support/Type.php +++ b/src/Folklore/GraphQL/Support/Type.php @@ -95,7 +95,12 @@ public function getAttributes() $attributes = array_merge($this->attributes, [ 'fields' => function () { - return $this->getFields(); + return array_merge( + array_merge(array_map(function($interface){ + return $interface->getFields(); + }, $interfaces)), + $this->getFields() + ); } ], $attributes); From 68d959cf0c5a7a47c50a8e259f128af27a204c4e Mon Sep 17 00:00:00 2001 From: Benedictus Arya Date: Thu, 7 Dec 2017 12:29:38 +0700 Subject: [PATCH 2/6] Update Type.php --- src/Folklore/GraphQL/Support/Type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Folklore/GraphQL/Support/Type.php b/src/Folklore/GraphQL/Support/Type.php index 54407a7a..d639b7cc 100644 --- a/src/Folklore/GraphQL/Support/Type.php +++ b/src/Folklore/GraphQL/Support/Type.php @@ -94,7 +94,7 @@ public function getAttributes() $interfaces = $this->interfaces(); $attributes = array_merge($this->attributes, [ - 'fields' => function () { + 'fields' => function () use ($interfaces) { return array_merge( array_merge(array_map(function($interface){ return $interface->getFields(); From f450c4e83b90e7fc803f5641c865db9c550b6161 Mon Sep 17 00:00:00 2001 From: Benedictus Arya Date: Thu, 7 Dec 2017 13:05:37 +0700 Subject: [PATCH 3/6] Update Type.php --- src/Folklore/GraphQL/Support/Type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Folklore/GraphQL/Support/Type.php b/src/Folklore/GraphQL/Support/Type.php index d639b7cc..689a0c75 100644 --- a/src/Folklore/GraphQL/Support/Type.php +++ b/src/Folklore/GraphQL/Support/Type.php @@ -96,7 +96,7 @@ public function getAttributes() $attributes = array_merge($this->attributes, [ 'fields' => function () use ($interfaces) { return array_merge( - array_merge(array_map(function($interface){ + call_user_func_array("array_merge", array_map(function($interface){ return $interface->getFields(); }, $interfaces)), $this->getFields() From 7d6d41151b9bb6d0ff2198becb404dd68e6422ea Mon Sep 17 00:00:00 2001 From: Benedictus Arya Date: Thu, 7 Dec 2017 13:16:56 +0700 Subject: [PATCH 4/6] Update Type.php --- src/Folklore/GraphQL/Support/Type.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Folklore/GraphQL/Support/Type.php b/src/Folklore/GraphQL/Support/Type.php index 689a0c75..7edc99ac 100644 --- a/src/Folklore/GraphQL/Support/Type.php +++ b/src/Folklore/GraphQL/Support/Type.php @@ -94,14 +94,13 @@ public function getAttributes() $interfaces = $this->interfaces(); $attributes = array_merge($this->attributes, [ - 'fields' => function () use ($interfaces) { - return array_merge( - call_user_func_array("array_merge", array_map(function($interface){ - return $interface->getFields(); - }, $interfaces)), - $this->getFields() - ); - } + 'fields' => array_merge(function () use ($interfaces) { + $fields = array_map(function ($interface) { + return $interface->getFields(); + }, $interfaces); + $fields[] = $this->getFields(); + return $fields; + }) ], $attributes); if (sizeof($interfaces)) { From d76d28bb8fe13b55fb8dc0a0ff39d0c336e29468 Mon Sep 17 00:00:00 2001 From: Benedictus Arya Date: Thu, 7 Dec 2017 13:19:15 +0700 Subject: [PATCH 5/6] Update Type.php --- src/Folklore/GraphQL/Support/Type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Folklore/GraphQL/Support/Type.php b/src/Folklore/GraphQL/Support/Type.php index 7edc99ac..17263aa1 100644 --- a/src/Folklore/GraphQL/Support/Type.php +++ b/src/Folklore/GraphQL/Support/Type.php @@ -94,7 +94,7 @@ public function getAttributes() $interfaces = $this->interfaces(); $attributes = array_merge($this->attributes, [ - 'fields' => array_merge(function () use ($interfaces) { + 'fields' => call_user_func_array("array_merge", function () use ($interfaces) { $fields = array_map(function ($interface) { return $interface->getFields(); }, $interfaces); From b7e1ce634c231f81139812f3ab6af129a5bd33bf Mon Sep 17 00:00:00 2001 From: Benedictus Arya Date: Thu, 7 Dec 2017 13:34:08 +0700 Subject: [PATCH 6/6] Update Type.php --- src/Folklore/GraphQL/Support/Type.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Folklore/GraphQL/Support/Type.php b/src/Folklore/GraphQL/Support/Type.php index 17263aa1..6d45f75d 100644 --- a/src/Folklore/GraphQL/Support/Type.php +++ b/src/Folklore/GraphQL/Support/Type.php @@ -94,13 +94,17 @@ public function getAttributes() $interfaces = $this->interfaces(); $attributes = array_merge($this->attributes, [ - 'fields' => call_user_func_array("array_merge", function () use ($interfaces) { - $fields = array_map(function ($interface) { - return $interface->getFields(); - }, $interfaces); - $fields[] = $this->getFields(); - return $fields; - }) + 'fields' => function () use ($interfaces) { + return array_merge( + call_user_func_array("array_merge", + array_map( function ($interface) { + return $interface->getFields(); + }, + $interfaces + )), + $this->getFields() + ); + } ], $attributes); if (sizeof($interfaces)) {