From 93ccd7351d2acceae23e4abffd1d4196d0d849d3 Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Wed, 19 Jun 2019 19:29:03 +0700 Subject: [PATCH] Array in variables in place of object shouldn't cause fatal error (fixes #467) --- src/Utils/Value.php | 2 +- tests/Regression/Issue467Test.php | 45 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/Regression/Issue467Test.php diff --git a/src/Utils/Value.php b/src/Utils/Value.php index 2bb053c..a427d3e 100644 --- a/src/Utils/Value.php +++ b/src/Utils/Value.php @@ -199,7 +199,7 @@ class Value } $suggestions = Utils::suggestionList( - $fieldName, + (string) $fieldName, array_keys($fields) ); $didYouMean = $suggestions diff --git a/tests/Regression/Issue467Test.php b/tests/Regression/Issue467Test.php new file mode 100644 index 0000000..988b4ac --- /dev/null +++ b/tests/Regression/Issue467Test.php @@ -0,0 +1,45 @@ + ['my message']]; + + $schema = BuildSchema::build($schemaStr); + $result = GraphQL::executeQuery($schema, $query, null, null, $variables); + + $expectedError = 'Variable "$msg" got invalid value ["my message"]; Field "0" is not defined by type MsgInput.'; + self::assertCount(1, $result->errors); + self::assertEquals($expectedError, $result->errors[0]->getMessage()); + } +}