Commit Graph

85 Commits

Author SHA1 Message Date
spawnia
24f236403a More consistent naming 2019-06-30 20:54:56 +02:00
Vladimir Razuvaev
261f8f5ebd AST: Replaced array with NodeList where missing 2019-06-19 15:52:16 +07:00
Simon Podlipsky
06529e1924 Upgrade Doctrine CS 2019-03-28 12:18:35 +01:00
Simon Podlipsky
d97fac6ab0 Invert instance of in BCFinder 2019-02-11 09:16:01 +01:00
Torsten Blindert
9609d2ac84 TASK: Code style 2018-12-05 19:23:07 +01:00
Torsten Blindert
d5fddfd504 TASK: Added test 2018-12-05 19:13:32 +01:00
Vladimir Razuvaev
1a1bf17c6a Added test case for extended schema resolvers 2018-11-03 16:01:41 +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
Torsten Blindert
e7de069bd5 FEATURE: SchemaExtender (#362)
FEATURE: SchemaExtender (#362)
2018-10-08 15:55:20 +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
Simon Podlipsky
450a1932e5
Fix typo and cleanup 2018-09-09 17:32:53 +02:00
Jeremiah VALERIE
62de403f27
Use right assert method 2018-09-02 17:20:38 +02:00
Simon Podlipsky
737da333fb
Fix CS in tests/Utils 2018-09-02 13:10:47 +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
804daa188e Add more BuildSchema tests + cleanup 2018-08-22 16:14:47 +07:00
Vladimir Razuvaev
f123e5c954 Remove redundancy in schema printer tests 2018-08-22 15:41:26 +07:00
Vladimir Razuvaev
9ae8b9f26e Merge branch 'master' of https://github.com/webonyx/graphql-php
# Conflicts:
#	src/Utils/AST.php
2018-08-22 11:43:30 +07:00
Simon Podlipsky
49f34d3243
Fix CS in Utils 2018-08-22 02:51:55 +02:00
Vladimir Razuvaev
56e91d008e Update printSchema for recent SDL change to implements 2018-08-08 15:07:08 +07:00
Vladimir Razuvaev
fcb9c24bb5 Fix astFromValue to correctly handle integers and strings 2018-08-08 14:57:44 +07:00
Simon Podlipsky
24b6b736b2
Upgrade PHPUnit 2018-07-29 19:01:39 +02:00
Daniel Tschinder
6e64983f82 Use multi-line block for trailing quote
ref: fdc10bb918 (diff-ebaed8492e8d884ee4f2255e39909568)
2018-06-25 14:26:53 +02:00
Daniel Tschinder
3e067cc60f Readd type decorator and fix lazy type loading 2018-03-06 12:53:28 +01:00
Daniel Tschinder
dc6e814de3 Fix orList to be the same as in JS and follow the chicago style for commas 2018-02-16 16:39:59 +01: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
48c5e64a08 Adding an interface to a type is now a dangerous change.
ref: graphql/graphql-js#992
2018-02-16 15:30:27 +01:00
Daniel Tschinder
d71b45d60e Find breaking directive changes
ref: graphql/graphql-js#1152
2018-02-16 00:15:19 +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
17520876d8 Update some validators to latest upstream version
This includes:
graphql/graphql-js#1147
graphql/graphql-js#355

This also fixes two bugs in the Schema
 - types that were not found where still added to the typeMap
 - InputObject args should not be searched for types.
2018-02-15 17:19:53 +01:00
Daniel Tschinder
97e8a9e200 Move schema validation into separate step (type constructors)
This is the second step of moving work from type constructors to the schema validation function.

ref: graphql/graphql-js#1132
2018-02-15 12:14:08 +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
481cdc9a82 Include test that printSchema includes non-spec directives.
ref: graphql/graphql-js@007407deb0

Also fixes expected <-> actual in this testfile
2018-02-11 21:32:40 +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
2cbccb87db Remove duplicated code from buildASTSchema and extendSchema
ref: graphql/graphql-js#1000

BREAKING CHANGE: SchemaBuilder::build() and buildAST() and constructor
removed the typedecorator, as not needed anymore as library can now resolve
union and interfaces from generated schemas.
2018-02-10 18:45:32 +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
2123946dbd Add warnings for nullable changes
ref: db4cfdc31d
ref: graphql/graphql-js#1096

# Conflicts:
#	tests/Utils/FindBreakingChangesTest.php
2018-02-10 18:45:18 +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
Daniel Tschinder
022c490011 RFC: Descriptions as strings
As discussed in facebook/graphql#90

This proposes replacing leading comment blocks as descriptions in the schema definition language with leading strings (typically block strings).

While I think there is some reduced ergonomics of using a string literal instead of a comment to write descriptions (unless perhaps you are accustomed to Python or Clojure), there are some compelling advantages:

* Descriptions are first-class in the AST of the schema definition language.
* Comments can remain "ignored" characters.
* No ambiguity between commented out regions and descriptions.

Specific to this reference implementation, since this is a breaking change and comment descriptions in the experimental SDL have fairly wide usage, I've left the comment description implementation intact and allow it to be enabled via an option. This should help with allowing upgrading with minimal impact on existing codebases and aid in automated transforms.

BREAKING CHANGE: This does not parse descriptions from comments by default anymore and the value of description in Nodes changed from string to StringValueNode
2018-02-10 18:44:51 +01:00
Adrien Crivelli
5cbaf973e1
Leverage PHPUnit setExpectedException() instead of custom code
Closes #219
2018-01-01 18:06:08 +09:00
Ben Roberts
b18dfd670f testFindsAllDangerousChanges 2017-11-21 12:30:18 -05:00
Ben Roberts
533b8b8b5f testDetectsAdditionsToUnionType 2017-11-21 12:18:28 -05:00
Ben Roberts
e0a63ec792 testDetectsEnumValueAdditions 2017-11-21 11:53:14 -05:00
Ben Roberts
c4ae03454a testFindDangerousArgChanges 2017-11-21 11:50:11 -05:00
Ben Roberts
3c0ed787ba testDetectsAllBreakingChanges 2017-11-21 11:33:45 -05:00
Ben Roberts
dbccf9b196 testDetectsRemovalOfInterfaces 2017-11-20 14:39:06 -05:00