Commit Graph

881 Commits

Author SHA1 Message Date
Daniel Tschinder
58453c31f7 Improve validation error message when field names conflict
ref: graphql/graphql-js#363
2018-02-11 14:11:21 +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
0c32982171 Fix KnownDirectives validator to support all directives 2018-02-11 13:15:51 +01:00
Daniel Tschinder
d6add77540 Add Docs 2018-02-10 18:46:37 +01:00
Daniel Tschinder
1da3801614 Add predicates to for built-in types
ref: graphql/graphql-js#924
2018-02-10 18:45:52 +01:00
Daniel Tschinder
c4f11a577e Allow to extend GraphQL errors with additional properties
ref: graphql/graphql-js#928
2018-02-10 18:45:38 +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
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
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
17a8c26fc9 Simplify operationTypes validation
ref: graphql/graphql-js#999

# Conflicts:
#	src/Utils/BuildSchema.php
2018-02-10 18:45:14 +01:00
Daniel Tschinder
1fdb3da7fb Remove notes about subscription being experimental
ref: graphql/graphql-js#bf4a25a33a62280e82680518adc279e34ec816e0
2018-02-10 18:45:10 +01:00
Daniel Tschinder
98e397ce44 Add additional number lexing test
ref: graphql/graphql-js#72421378550cf51b13c6db59b8fc912591fd1a4b
2018-02-10 18:45:06 +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
7705e50e44 Fix print of block string with leading space and quotation
ref: graphql/graphql-js#1190
2018-02-10 18:44:56 +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
Daniel Tschinder
e65638f6f4 Improvements to printing block strings
ref: graphql/graphql-js#f9e67c403a4667372684ee8c3e82e1f0ba27031b
2018-02-10 18:44:45 +01:00
Daniel Tschinder
8747ff8954 RFC: Block String
This RFC adds a new form of `StringValue`, the multi-line string, similar to that found in Python and Scala.

A multi-line string starts and ends with a triple-quote:

```
"""This is a triple-quoted string
and it can contain multiple lines"""
```

Multi-line strings are useful for typing literal bodies of text where new lines should be interpretted literally. In fact, the only escape sequence used is `\"""` and `\` is otherwise allowed unescaped. This is beneficial when writing documentation within strings which may reference the back-slash often:

```
"""
In a multi-line string \n and C:\\ are unescaped.
"""
```

The primary value of multi-line strings are to write long-form input directly in query text, in tools like GraphiQL, and as a prerequisite to another pending RFC to allow docstring style documentation in the Schema Definition Language.

Ref: graphql/graphql-js#926
2018-02-10 18:43:26 +01:00
Daniel Tschinder
46816a7cda Uniform parsing of queries with short-hand syntax with regular queries 2018-02-09 14:33:04 +01:00
Daniel Tschinder
eb9ac66af8 Fix how TypeInfo handles inline fragments without type
ref: graphql/graphql-js#1041
2018-02-09 14:32:44 +01:00
Vladimir Razuvaev
94525c0025
Merge pull request #234 from mcg-web/some-fixes
Some fast fixes
2018-02-08 11:39:15 +07:00
Jeremiah VALERIE
944ccebc08
Fix Utils::printSafe with bool true 2018-02-02 08:18:46 +01:00
Vladimir Razuvaev
ccecc3ce1b
Merge pull request #232 from Poky85/fix-content-type-header
Fix Standard Server PSR request parsing
2018-01-22 13:21:18 +07:00
Jiri Pokorny
dca2091351 Fix content-type header match when parsing PSR request. 2018-01-21 21:02:43 +01:00
Vladimir Razuvaev
7310b25730 Switched license to MIT for full compatibility with graphql-js 2018-01-19 14:12:52 +07:00
Vladimir Razuvaev
8cd154776e Added graphql-upload to the list of complementary tools 2018-01-19 13:58:07 +07:00
Vladimir Razuvaev
4f223ba11d Fixed PSR request parsing, broken after recent changes 2018-01-13 18:08:07 +07:00
Vladimir Razuvaev
918bbff2bd
Merge branch 'master' into no-parsing 2018-01-13 17:20:00 +07:00
Vladimir Razuvaev
9944a689bf Exclude nulls from serialized AST 2018-01-13 16:25:06 +07:00
Vladimir Razuvaev
8b17953fe5 Fixed bug preventing use of parser noLocation option for serialization / deserialization 2018-01-13 15:45:09 +07:00
Vladimir Razuvaev
61f6ccfe76
Merge pull request #222 from giansalex/master
Exclude files in release
2018-01-02 22:43:31 +07:00
Giancarlos Salas
90978ea78d
update ignore files 2018-01-02 10:02:18 -05:00
Vladimir Razuvaev
7c3737609f Doc-block fix 2018-01-01 22:12:51 +07:00
Vladimir Razuvaev
b534bfbbf1 Docs: Mention PSR15-compliant middleware in complementary tools section 2018-01-01 22:07:15 +07:00
Vladimir Razuvaev
88db2f8a21
Merge pull request #224 from PowerKiKi/concise-tests
Leverage PHPUnit `setExpectedException()` instead of custom code
2018-01-01 21:33:08 +07:00
Adrien Crivelli
5cbaf973e1
Leverage PHPUnit setExpectedException() instead of custom code
Closes #219
2018-01-01 18:06:08 +09:00
Giancarlos Salas
5c6f69c254 exclude files in release 2017-12-29 21:01:42 -05:00
Adrien Crivelli
178b179db3
Drop support non pre-parsed PSR-7 request body
This revert #202 (commit 9d37f4c) because trying to parse PSR-7 request
was a mistake. The whole point of PSR-7 is to allow for interoperability
and be able to use specialized libs for body parsing (amongst many other
things). Trying to parse ourselves would be opening a can of worm if/when
other content types have to be supported. It is more correct and future
safe to require that the body is parsed before being passed to GraphQL.
2017-12-21 15:01:57 +09:00
Vladimir Razuvaev
a3f18b51f7
Merge pull request #211 from enumag/patch-2
indentation fix
2017-12-13 14:24:29 +07:00
Jáchym Toušek
f6c3fe3758
indentation 2017-12-12 13:36:20 +01:00
Vladimir Razuvaev
b97cad0f4a v0.11.5 2017-12-12 16:03:21 +07:00
Vladimir Razuvaev
bb75586aa5
Merge pull request #210 from enumag/patch-1
Allow objects with __toString in IDType
2017-12-12 16:02:09 +07:00
Jáchym Toušek
9e2c1dae87
Add test 2017-12-12 09:53:15 +01:00
Jáchym Toušek
25e341e9d9
Allow objects with __toString in IDType 2017-12-12 08:56:03 +01:00
Vladimir Razuvaev
3536280fac v0.11.4 2017-11-28 20:27:06 +07:00
Vladimir Razuvaev
9c563d5c00
Merge pull request #199 from roippi/findbreakingchanges
port findBreakingChanges
2017-11-28 20:14:36 +07:00
Vladimir Razuvaev
ea05c92723 v0.11.3 2017-11-28 12:38:56 +07:00
Vladimir Razuvaev
0af2fe79f2 StandardServer: a bit more validation for parsed json PSR-7 request (related to #202) 2017-11-28 12:28:54 +07:00
Vladimir Razuvaev
9d37f4c0d9
Merge pull request #202 from PowerKiKi/support-non-parsed-psr7
Support non pre-parsed PSR-7 request body
2017-11-28 12:01:15 +07:00
Adrien Crivelli
11c9429fab
Support non pre-parsed PSR-7 request body
Because PSR-7 specification only specify that `getParsedBody()` **may**
return the parsed body for `application/json`, we cannot assume that it
is always the case. So if the value returned parsed body is an empty array,
it means we should try to parse it ourselves (`null` would mean no body at
all according to spec).

With this modification we try to used given parsed body, but fallback on
trying to parse the body if necessary. This leave the door open to custom
implementation of parsing if needed, while making it easier to use out of
the box.
2017-11-26 19:57:32 +09:00