Commit Graph

114 Commits

Author SHA1 Message Date
Benedikt Franke
3b33167c87 Rename $rootValue where applicable 2019-07-01 12:12:01 +02:00
Benedikt Franke
d037ab7ec3 Merge branch 'master' into root-value-consistent-naming
# Conflicts:
#	docs/data-fetching.md
#	src/Executor/Executor.php
#	tests/Executor/DeferredFieldsTest.php
2019-07-01 08:23:00 +02:00
spawnia
c069d20ca7 And a few more in tests 2019-06-30 23:09:32 +02:00
spawnia
24f236403a More consistent naming 2019-06-30 20:54:56 +02:00
spawnia
8da3043702 Rename some test variable names 2019-06-23 21:26:38 +02:00
spawnia
9ca7bb6ea1 Expand one letter variable names 2019-06-23 18:42:25 +02:00
Vladimir Razuvaev
11d32d4568
Merge pull request #465 from mll-lab/enum-default-values
Enum default values
2019-03-29 15:41:12 +07:00
spawnia
db915d8812 Fix codestyle 2019-03-29 09:27:33 +01:00
Simon Podlipsky
06529e1924 Upgrade Doctrine CS 2019-03-28 12:18:35 +01:00
spawnia
ddebd9a414 Add test for default enum input coercion 2019-03-28 11:26:30 +01:00
Jonas Elfering
5b3f44c7a3 add queryplan 2019-02-01 22:39:00 +01:00
Jan Bukva
2295b96a49
Fix CoroutineExecutor::resultToArray for associative arrays 2018-12-27 16:38:40 +01:00
Jan Bukva
31d89acfae
Failing test for CoroutineExecutor removes associative array when using custom scalar producing JSON 2018-12-27 16:01:27 +01:00
Vladimir Razuvaev
c45fa1a4b1 Default Error Formatting: Display error category under extensions key (#389) 2018-11-27 16:37:33 +07:00
Vladimir Razuvaev
9cb6b4e6f3 Additional tests for errors with extensions 2018-11-22 19:47:10 +07:00
Vladimir Razuvaev
c0ae3ccdaf Fix possessive its vs contraction it's (resolving conflicts) 2018-11-22 18:43:35 +07:00
Mark Huot
4811cd198f
Fixing test for possessive/contraction "its" change 2018-11-19 09:13:57 -05:00
Jakub Kulhan
b5d3341995 Pluggable executor implementations; new faster executor using coroutines 2018-11-06 23:32:50 +01:00
David B. Nagle
f39f0f5517 Fixed misspelling "defintion" in several places 2018-11-03 15:35:18 -07:00
Vladimir Razuvaev
6cce6742eb
Merge pull request #367 from simPod/phpstan-strict
Use PHPStan strict rules
2018-10-22 17:28:59 +02:00
Vladimir Razuvaev
c7fcd4eb48 Got rid of PHP_EOL usages (we never do or expect carriage returns) 2018-10-10 11:26:48 +02:00
Simon Podlipsky
90d0156291
Use PHPStan strict rules
Two rules excluded: missing type hints and empty() usage
2018-10-09 17:46:55 +02:00
Simon Podlipsky
07c070d795
Fix CS in tests 2018-10-05 10:47:57 +02:00
Simon Podlipsky
c4e06ba528
Use self:: in tests where appropriate 2018-09-19 20:50:32 +02:00
Jeremiah VALERIE
62de403f27
Use right assert method 2018-09-02 17:20:38 +02:00
Jeremiah VALERIE
eb7ff7048d
Removed unused use for anonymous functions 2018-09-02 17:20:38 +02:00
Simon Podlipsky
b02d25e62c
Fix CS in tests/Executor 2018-09-01 20:05:38 +02:00
Simon Podlipsky
715146cdd1
Add void return typehint to test methods 2018-08-31 14:41:18 +02:00
Simon Podlipsky
a30b3104a0
Replace misleading @it by @see annotation 2018-08-31 10:55:14 +02:00
Vladimir Razuvaev
ea6a21a13b Cleanup variables test 2018-08-22 18:40:15 +07:00
Vladimir Razuvaev
227f0b867d Serial execution should support sync execution (+tests for the serial execution) 2018-08-22 15:10:10 +07:00
Vladimir Razuvaev
03d7d1851c NonNull test: fixed naming for consistency 2018-08-08 01:43:23 +07:00
Vladimir Razuvaev
4227404aee Added test for useful error when returning invalid value from resolveType 2018-08-07 23:33:20 +07:00
Simon Podlipsky
24b6b736b2
Upgrade PHPUnit 2018-07-29 19:01:39 +02:00
Vladimir Razuvaev
9452655fcd
Merge pull request #281 from icerockdev/master
Removing data elements from response if the error throwing
2018-05-27 20:02:14 +07:00
Vladimir Razuvaev
1b22f95a86 Removed previously deprecated classes/methods 2018-05-27 19:13:32 +07:00
Ilya Shaydullin
c7f114d90b Removing data elements from response if the error throwing 2018-05-07 17:01:18 +07:00
Daniel Tschinder
f140149127 Make Types throw instead of returning Utils::undefined() 2018-04-24 15:14:31 +02:00
Daniel Tschinder
d92a2dab21 Add suggestions for invalid values
For misspelled enums or field names, these suggestions can be helpful.

This also changes the suggestions algorithm to better detect case-sensitivity mistakes, which are common

ref: graphql/graphql-js#1153
2018-02-16 16:19:25 +01:00
Daniel Tschinder
58e0c7a178 Validate literals in a single rule with finer precision
This generalizes the "arguments of correct type" and "default values of correct type" to a single rule "values of correct type" which has been re-written to rely on a traversal rather than the utility function `isValidLiteralValue`. To reduce breaking scope, this does not remove that utility even though it's no longer used directly within the library. Since the default values rule included another validation rule that rule was renamed to a more apt "variable default value allowed".

This also includes the original errors from custom scalars in the validation error output, solving the remainder of graphql/graphql-js#821.

ref: graphql/graphql-js#1144
2018-02-15 21:29:14 +01:00
Daniel Tschinder
60df83f47e Preserve original coercion errors, improve error quality.
This is a fairly major refactoring of coerceValue which returns an Either so it can return a complete collection of errors. This allows originalError to be preserved for scalar coercion errors and ensures *all* errors are represented in the response.

This had a minor change to the logic in execute / subscribe to allow for buildExecutionContext to abrupt complete with multiple errors.

ref: graphql/graphql-js#1133
2018-02-13 16:51:44 +01:00
Daniel Tschinder
d70a9a5e53 Update to match SDL changes
This changes the parsing grammar and validation rules to more correctly implement the current state of the GraphQL SDL proposal (facebook/graphql#90)

ref: graphql/graphl-js#1102
2018-02-11 13:27:26 +01:00
Daniel Tschinder
27ce24b5fe Fix parsing of default values in build-schema
* Generalizes building a value from an AST, since "scalar" could be misleading, and supporting variable values within custom scalar literals can be valuable.
* Replaces isNullish with isInvalid since `null` is a meaningful value as a result of literal parsing.
* Provide reasonable default version of 'parseLiteral'

ref: 714ee980aa
ref: https://github.com/graphql/graphql-js/pull/903

# Conflicts:
#	src/Utils/BuildSchema.php
#	tests/Utils/BuildSchemaTest.php
2018-02-10 18:45:23 +01:00
Daniel Tschinder
4e26de3588 Support for union types when using buildSchema
* Adds support for resolving union/interface types when using a generated schema
* Move resolveType __typename checking into defaultResolveType
* Clean up existing tests and improve error messages

ref: graphql/graphql-js#947

# Conflicts:
#	src/Utils/BuildSchema.php
#	tests/Utils/BuildSchemaTest.php
2018-02-10 18:45:01 +01:00
Adrien Crivelli
5cbaf973e1
Leverage PHPUnit setExpectedException() instead of custom code
Closes #219
2018-01-01 18:06:08 +09:00
Vladimir Razuvaev
1e34982bda Additional tests for variable coercion + use printSafeJson vs printSafe for input variables 2017-09-20 18:40:45 +07:00
Vladimir Razuvaev
39f378ece7 Fixed type in tests: Testcase -> TestCase 2017-09-20 17:03:22 +07:00
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
90602b31ba Added link to docs for generic error about unique type instance (#149) 2017-08-20 22:28:17 +07:00
Vladimir Razuvaev
1b4f983f3f Improved docblock comments (suitable for reference docs generation) 2017-08-19 23:01:46 +07:00