Commit Graph

142 Commits

Author SHA1 Message Date
Vladimir Razuvaev
c0ae3ccdaf Fix possessive its vs contraction it's (resolving conflicts) 2018-11-22 18:43:35 +07:00
Vladimir Razuvaev
779774b162 ReferenceExecutor: Remove excessive arguments 2018-11-21 18:54:11 +07:00
Mark Huot
7249e2611a
Fix possessive its vs contraction it's 2018-11-11 07:59:45 -05:00
Jakub Kulhan
b5d3341995 Pluggable executor implementations; new faster executor using coroutines 2018-11-06 23:32:50 +01:00
Simon Podlipsky
644f97634b Little fixes 2018-10-22 23:37:28 +02: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
5fb970b3f1 Codestyle fix 2018-10-10 11:41:24 +02:00
Vladimir Razuvaev
4bc9dfc6f8 Reverted unneeded change in the defaultFieldResolver 2018-10-10 11:29:14 +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
Gilles Maes
7ff3e9399f Expand is_array check in defaultTypeResolver to allow for ArrayAccess… (#361)
Expand is_array check in defaultTypeResolver to allow for ArrayAccess objects as well
2018-10-08 15:53:07 +02:00
Simon Podlipsky
bfebcd7bee
Fix CS in src/Executor 2018-10-05 10:47:57 +02:00
Jeremiah VALERIE
d8f41e854f
Add static analysis tool 2018-09-02 17:19:15 +02:00
Simon Podlipsky
76e1c33b68
Fix CS in src 2018-09-02 10:39:03 +02:00
Simon Podlipsky
00d547dc06
Fix CS in src/Type 2018-08-27 18:14:07 +02: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
4227404aee Added test for useful error when returning invalid value from resolveType 2018-08-07 23:33:20 +07:00
Vladimir Razuvaev
2f2b54a3d6 Perf: memoize collectSubfields 2018-07-30 00:36:10 +07:00
Simon Podlipsky
1b42de0658
@return self 2018-07-10 01:34:35 +03:00
Simon Podlipsky
cd1cc911e7
Refactoring 2018-06-26 14:37:19 +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
06490cae8b Fix is null condition 2018-05-07 17:12:21 +07:00
Ilya Shaydullin
c7f114d90b Removing data elements from response if the error throwing 2018-05-07 17:01:18 +07:00
Daniel Tschinder
62748279d4 Cleanup imports 2018-04-24 15:38:44 +02:00
Daniel Tschinder
f140149127 Make Types throw instead of returning Utils::undefined() 2018-04-24 15:14:31 +02: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
06c6c4bd97 Validate schema root types and directives
This moves validation out of GraphQLSchema's constructor (but not yet from other type constructors), which is responsible for root type validation and interface implementation checking.

Reduces time to construct GraphQLSchema significantly, shifting the time to validation.

This also allows for much looser rules within the schema builders, which implicitly validate while trying to adhere to flow types. Instead we use any casts to loosen the rules to defer that to validation where errors can be richer.

This also loosens the rule that a schema can only be constructed if it has a query type, moving that to validation as well. That makes flow typing slightly less nice, but allows for incremental schema building which is valuable

ref: graphql/graphql-js#1124
2018-02-13 10:42:35 +01:00
Daniel Tschinder
f661f38215 Fix unhandled error when parsing custom scalar literals.
This factors out the enum value validation from scalar value validation and ensures the same try/catch is used in isValidLiteralValue as isValidPHPValue and protecting from errors in valueFromAST.
ref: graphql/graphql-js#1126
2018-02-11 22:31:04 +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
48c33302a8 (Potentially Breaking) Allow serializing scalars as null.
This changes the check for null/undefined to a check for undefined to determine if scalar serialization was successful or not, allowing `null` to be returned from serialize() without indicating error.

This is potentially breaking for any existing custom scalar which returned `null` from `serialize()` to indicate failure. To account for this change, it should either throw an error or return `undefined`.

ref: graphql/graphql-js#1104
2018-02-10 18:45:27 +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
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
6fdcfd9bb0 Merge branch 'master' of https://github.com/webonyx/graphql-php into v0.10 2017-08-20 23:16:51 +07: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
d5e3d08d85 Minor Executor tweaks 2017-08-20 20:09:55 +07:00
Vladimir Razuvaev
bd444752f8 Documentation and docblock improvements 2017-08-20 16:00:44 +07:00
Vladimir Razuvaev
1b4f983f3f Improved docblock comments (suitable for reference docs generation) 2017-08-19 23:01:46 +07:00
Jeremiah VALERIE
1c143360ca Add hooks to helps promise completion with custom backend 2017-08-18 16:18:48 +02:00
Vladimir Razuvaev
d578b8a22f Split sync and async facade methods 2017-08-18 01:49:10 +07:00
Vladimir Razuvaev
03629c1e3c Refactored error formatting (debugging part) 2017-08-17 18:49:17 +07:00
Vladimir Razuvaev
b56083b7de Improved flexibility of error handling 2017-08-17 02:11:21 +07:00
Vladimir Razuvaev
e4813c3a05 Additional checks and tests for situations when user-land code returns duplicate type instances 2017-08-14 23:52:17 +07:00
Vladimir Razuvaev
b9d3a11785 Extracted lazy schema test; minor related refactoring 2017-08-14 20:41:08 +07:00
Vladimir Razuvaev
20f8cab943 Removed schema descriptor (as lazy loading of types can work without it now) 2017-08-14 01:42:02 +07:00
Vladimir Razuvaev
d3580e959e Moved Schema to GraphQL\Type namespace (but preserved BC) 2017-08-12 21:40:03 +07:00
Vladimir Razuvaev
1af902865b AST: new NodeList class for collections of nodes (vs array) to enable effective conversion of libgraphqlparser output to our AST tree 2017-07-21 22:29:59 +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
24ffd605f4 New method "Executor::promiseToExecute()" which always returns promise (even for SyncPromiseAdapter) 2017-07-17 19:47:29 +07:00