Commit Graph

831 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
79ebc54538 Minor docs improvements 2017-09-05 15:29:46 +07:00
Vladimir Razuvaev
7cc863df37 v0.10.2 2017-08-30 23:33:58 +07:00
Vladimir Razuvaev
6ff427d241 Server: do not raise an error when variables are passed as empty string (#156) 2017-08-30 23:26:45 +07:00
Vladimir Razuvaev
46477c75c4 Added entry about graphql.org in the README + minor README tweaks 2017-08-22 17:24:17 +07:00
Vladimir Razuvaev
524a01a3a4 Fixed typos and mistakes in README 2017-08-22 17:11:48 +07:00
Vladimir Razuvaev
2ccc631ff3 Added CONTRIBUTING.md and updated README.md 2017-08-22 17:05:54 +07:00
Vladimir Razuvaev
1eb2ccac76 v0.10.1 2017-08-21 01:27:58 +07:00
Vladimir Razuvaev
d95fb461ee Server: fixed constructor screwed during rebasing + restored tests for the server 2017-08-21 01:18:23 +07:00
Vladimir Razuvaev
a1652468f0 Fixed minor error in docblock comment 2017-08-21 00:19:07 +07:00
Vladimir Razuvaev
df1b575469 Changed CHANGELOG documentation links to documentation site 2017-08-20 23:25:48 +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
cbc744ea08 Added entries about deprecation of old server and type resolution strategies to UPGRADE.md document 2017-08-20 23:16:23 +07:00
Vladimir Razuvaev
1f68909eb0 Added CHANGELOG document 2017-08-20 23:15:22 +07:00
Vladimir Razuvaev
a3b6974249 Added entry in docs about schema config class 2017-08-20 22:59:40 +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
7f346d5658 Documentation improvements 2017-08-20 22:10:37 +07:00
Vladimir Razuvaev
de791536ce Docblocks improvements 2017-08-20 22:10:13 +07:00
Vladimir Razuvaev
d5e3d08d85 Minor Executor tweaks 2017-08-20 20:09:55 +07:00
Vladimir Razuvaev
085516bdda Moved GraphQL\Language\AST\Node::fromArray to GraphQL\Utils\AST::fromArray 2017-08-20 19:50:44 +07:00
Vladimir Razuvaev
bd444752f8 Documentation and docblock improvements 2017-08-20 16:00:44 +07:00
Vladimir Razuvaev
199caf3080 New example for server usage 2017-08-20 02:33:16 +07:00
Vladimir Razuvaev
71343f2f62 Server: Extracted method for emitting response 2017-08-20 02:32:50 +07:00
Vladimir Razuvaev
8098b2b886 Fixing examples 2017-08-20 02:31:11 +07:00
Vladimir Razuvaev
009cdecb94 Reference docs generated from docblocks 2017-08-19 23:02:34 +07:00
Vladimir Razuvaev
1b4f983f3f Improved docblock comments (suitable for reference docs generation) 2017-08-19 23:01:46 +07:00
Vladimir Razuvaev
3ef2d2827b Added psr/http-message as a dev dependency to ensure that unit tests run without additional deps installation steps 2017-08-19 22:58:44 +07:00
Vladimir Razuvaev
0af1fb2793 Reference docs generator 2017-08-19 22:57:26 +07:00
Vladimir Razuvaev
ed66291308 Merge pull request #152 from mcg-web/add-hooks-while-completing-sync-promise
Add hooks to helps promise completion with custom backend
2017-08-18 22:30:03 +07:00
Jeremiah VALERIE
1c143360ca Add hooks to helps promise completion with custom backend 2017-08-18 16:18:48 +02:00
Vladimir Razuvaev
99356f7faf Docs on security 2017-08-18 20:56:47 +07:00
Vladimir Razuvaev
4f374bca83 Docs about custom validation rules 2017-08-18 20:56:34 +07:00
Vladimir Razuvaev
203fddfe4e Abstract base class for validation rules 2017-08-18 20:56:04 +07:00
Vladimir Razuvaev
9499e5ae8e Suppressing Config deprecation warning in tests 2017-08-18 18:07:23 +07:00
Vladimir Razuvaev
637156fe65 Further documentation improvements 2017-08-18 02:56:22 +07:00
Vladimir Razuvaev
2537a62ec2 Documented server usage 2017-08-18 02:56:07 +07:00
Vladimir Razuvaev
2bfce65484 Fixed Parser docblock comments 2017-08-18 02:55:22 +07:00
Vladimir Razuvaev
83cc9132a0 Server: minor improvements 2017-08-18 02:54:35 +07:00
Vladimir Razuvaev
d578b8a22f Split sync and async facade methods 2017-08-18 01:49:10 +07:00
Vladimir Razuvaev
c04d037fb1 Documentation improvements 2017-08-17 20:35:58 +07:00
Vladimir Razuvaev
c65d8d8624 Documented lazy loading of types in schema and ability to define schema using GraphQL type language 2017-08-17 20:35:35 +07:00
Vladimir Razuvaev
e52fe8c384 BuildSchema::build() now accepts DocumentNode as well 2017-08-17 20:33:36 +07:00
Vladimir Razuvaev
03629c1e3c Refactored error formatting (debugging part) 2017-08-17 18:49:17 +07:00
Vladimir Razuvaev
1d38643538 Ability to re-throw resolver exceptions 2017-08-17 03:01:23 +07:00
Vladimir Razuvaev
a2be92937e Documentation improvements (wip) 2017-08-17 02:17:01 +07:00
Vladimir Razuvaev
b294329a40 Added reference section to docs 2017-08-17 02:16:45 +07:00
Vladimir Razuvaev
51e877bfba Improving docblock comments 2017-08-17 02:15:49 +07:00
Vladimir Razuvaev
b4d767bad6 Moved typeFromAST() to AST util 2017-08-17 02:14:55 +07:00
Vladimir Razuvaev
a50c9a4c1f Renamed error category constants 2017-08-17 02:13:44 +07:00
Vladimir Razuvaev
4634f214ea Revamping GraphQL facade methods 2017-08-17 02:12:37 +07:00