mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 04:46:04 +03:00
Writing UPGRADE.md
This commit is contained in:
parent
f911fac7b1
commit
2c8c7baa87
34
UPGRADE.md
34
UPGRADE.md
@ -1,6 +1,6 @@
|
|||||||
# Upgrade
|
# Upgrade
|
||||||
|
|
||||||
## Upgrade v0.9.x > v0.10.x
|
## Upgrade v0.8.x, v0.9.x > v0.10.x
|
||||||
### Breaking: default error formatting
|
### Breaking: default error formatting
|
||||||
By default exceptions thrown in resolvers will be reported with generic message `"Internal server error"`.
|
By default exceptions thrown in resolvers will be reported with generic message `"Internal server error"`.
|
||||||
Only exceptions implementing interface `GraphQL\Error\ClientAware` and claiming themselves as `safe` will
|
Only exceptions implementing interface `GraphQL\Error\ClientAware` and claiming themselves as `safe` will
|
||||||
@ -9,13 +9,16 @@ be reported with full error message.
|
|||||||
This is done to avoid information leak in production when unhandled exceptions occur in resolvers
|
This is done to avoid information leak in production when unhandled exceptions occur in resolvers
|
||||||
(e.g. database connection errors, file access errors, etc).
|
(e.g. database connection errors, file access errors, etc).
|
||||||
|
|
||||||
|
Also every error reported to client now has new `category` key which is either `graphql` or `internal`.
|
||||||
|
Exceptions implementing `ClientAware` interface may define their own custom categories.
|
||||||
|
|
||||||
During development or debugging use `$executionResult->toArray(true)`. It will add `debugMessage` key to
|
During development or debugging use `$executionResult->toArray(true)`. It will add `debugMessage` key to
|
||||||
each error entry in result. If you also want to add `trace` for each error - pass flags instead:
|
each error entry in result. If you also want to add `trace` for each error - pass flags instead:
|
||||||
|
|
||||||
```
|
```
|
||||||
use GraphQL\Error\FormattedError;
|
use GraphQL\Error\FormattedError;
|
||||||
$debug = FormattedError::INCLUDE_DEBUG_MESSAGE | FormattedError::INCLUDE_TRACE;
|
$debug = FormattedError::INCLUDE_DEBUG_MESSAGE | FormattedError::INCLUDE_TRACE;
|
||||||
$result = GraphQL::executeAndReturnResult()->toArray($debug);
|
$result = GraphQL::executeAndReturnResult(/*args*/)->toArray($debug);
|
||||||
```
|
```
|
||||||
|
|
||||||
To change default `"Internal server error"` message to something else, use:
|
To change default `"Internal server error"` message to something else, use:
|
||||||
@ -26,19 +29,30 @@ GraphQL\Error\FormattedError::setInternalErrorMessage("Unexpected error");
|
|||||||
**This change only affects default error reporting mechanism. If you set your own error formatter using
|
**This change only affects default error reporting mechanism. If you set your own error formatter using
|
||||||
`ExecutionResult::setErrorFormatter()` you won't be affected by this change.**
|
`ExecutionResult::setErrorFormatter()` you won't be affected by this change.**
|
||||||
|
|
||||||
If default formatting doesn't work for you - just set [your own error
|
If new default formatting doesn't work for you - just set [your own error
|
||||||
formatter](http://webonyx.github.io/graphql-php/error-handling/#custom-error-formatting).
|
formatter](http://webonyx.github.io/graphql-php/error-handling/#custom-error-formatting).
|
||||||
|
|
||||||
### Breaking: `GraphQL\Error\UserError` base class
|
### Breaking: AST now uses `NodeList` vs array for lists of nodes
|
||||||
`GraphQL\Error\UserError` now extends `\RuntimeException` (previously it was extending
|
It helps us unserialize AST from array lazily. This change affects you only if you use `array_`
|
||||||
`GraphQL\Error\InvariantViolation`).
|
functions with AST or mutate AST directly.
|
||||||
|
|
||||||
**This may affect authors of derived libraries and those using custom error formatting.**
|
Before the change:
|
||||||
If you were catching `InvariantViolation` anywhere in your code, you should also catch `UserError` now.
|
```php
|
||||||
|
new GraphQL\Language\AST\DocumentNode([
|
||||||
|
'definitions' => array(/*...*/)
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
After the change:
|
||||||
|
```
|
||||||
|
new GraphQL\Language\AST\DocumentNode([
|
||||||
|
'definitions' => new NodeList([/*...*/])
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
Same applies to `instanceof` checks.
|
|
||||||
|
|
||||||
`UserError` is thrown when library detects invalid input from client.
|
### Breaking: scalar types now throw different exceptions when parsing and serializing
|
||||||
|
On invalid user input they throw standard `GraphQL\Error\Error` now, but when they
|
||||||
|
encounter invalid output during serialization they throw `GraphQL\Error\InvariantViolation`.
|
||||||
|
|
||||||
|
|
||||||
### Deprecated: `GraphQL\Utils` moved to `GraphQL\Utils\Utils`
|
### Deprecated: `GraphQL\Utils` moved to `GraphQL\Utils\Utils`
|
||||||
|
Loading…
Reference in New Issue
Block a user