Commit Graph

27 Commits

Author SHA1 Message Date
Derek Lavigne
d22385cc93 Update query variable coercion to meet the rules outlined in the
specification.

The framework currently coerces query variables similar to the way it
treats output values, which means it attempts to coerce the value into
the field's corresponding data type regardless of the received value.
According to items 3f and 3g in section 6.1.2
(http://facebook.github.io/graphql/#sec-Validating-Requests) of
Facebook's GraphQL specification query variables should be coerced
according to their type's input coercion rules laid out in section
3.1.1 (http://facebook.github.io/graphql/#sec-Scalars). If the value
can not be coerced into the correct type according the the input
coercion rules for the type a query error should be thrown. This
ensures that client provided query variables were of the correct format
and will be a valid format and type by the time they are passed into an
implementing resolver.

This patch fixes the above issue by updating the way query variables
are sanitized during the process of parsing the query. It directly
follows the rules for scalar input coercion laid out by the
specification and throws query errors when a value that cannot be
coerced to the correct type is given. Tests for isValidPHPValue will
also be updated to ensure that it is doing the correct type checks on
Values::isValidPHPValue for the given type and value provided. A new
test case will also be added to test Values::getVariableValues and make
sure it is also enforcing the scalar input coercion rules and throwing
errors for invalid values.
2017-09-18 12:14:09 -04:00
Vladimir Razuvaev
f911fac7b1 Default error reporting now includes "category" key for every error 2017-08-08 02:02:07 +07:00
Vladimir Razuvaev
38922dbbed Default error formatter now returns "Internal server error" unless error is client-aware and safe to report directly to end-users 2017-07-18 20:57:30 +07:00
Vladimir Razuvaev
9b9a74c1d1 Spec compliance: errors in buildExecutionContext() are caught and included in result rather than thrown 2017-07-05 17:33:59 +07:00
Vladimir Razuvaev
78d9ba0d5e Allow providing default field resolver for execution call 2017-07-05 16:22:01 +07:00
Vladimir Razuvaev
34bd378c7e Refactored executor logic related to isTypeOf 2017-07-04 00:09:32 +07:00
vladar
ff3a40d329 Execution: modified deferred behavior to be more predictable (+added more tests for them) 2016-12-17 05:14:51 +07:00
vladar
fd335a1d13 Execution: tests are green 2016-12-03 04:23:21 +07:00
Jeremiah VALERIE
76c31df1af Add Executor Promise tests 2016-11-26 23:51:42 +01:00
vladar
63d44fe002 Disabled deprecation notice for ResolveInfo->fieldASTs (until next version) 2016-11-19 17:37:54 +07:00
vladar
0ab55ec0d9 Replaced "AST" with "Node" in variable names for better readability 2016-11-19 06:47:55 +07:00
vladar
8a676cde99 Support for NullValue 2016-11-18 23:59:28 +07:00
vladar
c11f25794a Deprecated callbacks in "type" option of field/argument definitions (see #35) 2016-10-23 00:49:25 +07:00
vladar
a612b780c9 Return stdClass vs empty array for empty ObjectType values (see #59) 2016-10-22 17:16:47 +07:00
vladar
2675b65095 Moved all error-related classes to separate namespace; fixed related broken tests 2016-10-21 16:40:56 +07:00
vladar
6d7a4a4f34 Fixed tests broken by recent changes to serialized error format 2016-10-21 15:28:24 +07:00
vladar
a94640f9d2 Enabled GraphQL\Error to include path to failed value during execution step (not location in source query, but exact path to value, including index in array, etc) + tests for errors 2016-10-18 22:15:21 +07:00
vladar
c0f7ec099d Several executor tests 2016-10-18 20:30:15 +07:00
vladar
c3d7a49a08 Updated executor and it's tests for april2016 specs 2016-09-14 18:47:34 +07:00
Jeremiah VALERIE
3ae6c73367 Removed memoization on executor resolveField (see #43) 2016-06-10 11:57:43 +02:00
Jeremiah VALERIE
1bc5e0c9da Use PSR-4 Autoloader for tests 2016-04-09 14:14:40 +02:00
vladar
3b3da9e066 Several performance improvements (#8) 2015-10-25 14:23:15 +06:00
vladar
d982bad63a Make sure default argument values are passed to resolve function (#4) 2015-10-23 17:30:02 +06:00
vladar
83f42825f8 Reverted mapping executor (#6) 2015-10-23 15:44:01 +06:00
vladar
3edf6248b0 Mapping Executor 2015-09-01 01:44:03 +06:00
vladar
841d6ab851 Updated to latest version of graphql-js 2015-08-17 20:01:55 +06:00
vladar
20c482ce2f Version 0.1 2015-07-15 23:05:46 +06:00