Skip to content

Commit 90088c7

Browse files
committed
Note in UPGRADE.md about new base class of GraphQL\Error\UserError
1 parent 38922db commit 90088c7

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

UPGRADE.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Upgrade
22

33
## Upgrade v0.9.x > v0.10.x
4-
#### Breaking: default error formatting
4+
### Breaking: default error formatting
55
By default exceptions thrown in resolvers will be reported with generic message `"Internal server error"`.
66
Only exceptions implementing interface `GraphQL\Error\ClientAware` and claiming themselves as `safe` will
77
be reported with full error message.
@@ -26,18 +26,30 @@ GraphQL\Error\FormattedError::setInternalErrorMessage("Unexpected error");
2626
**This change only affects default error reporting mechanism. If you set your own error formatter using
2727
`ExecutionResult::setErrorFormatter()` you won't be affected by this change.**
2828

29-
If you are not happy with this change just set [your own error
29+
If default formatting doesn't work for you - just set [your own error
3030
formatter](http://webonyx.github.io/graphql-php/error-handling/#custom-error-formatting).
3131

32-
#### Deprecated: GraphQL\Utils moved to GraphQL\Utils\Utils
32+
### Breaking: `GraphQL\Error\UserError` base class
33+
`GraphQL\Error\UserError` now extends `\RuntimeException` (previously it was extending
34+
`GraphQL\Error\InvariantViolation`).
35+
36+
**This may affect authors of derived libraries and those using custom error formatting.**
37+
If you were catching `InvariantViolation` anywhere in your code, you should also catch `UserError` now.
38+
39+
Same applies to `instanceof` checks.
40+
41+
`UserError` is thrown when library detects invalid input from client.
42+
43+
44+
### Deprecated: `GraphQL\Utils` moved to `GraphQL\Utils\Utils`
3345
Old class still exists, but triggers deprecation warning when referenced.
3446

3547
## Upgrade v0.7.x > v0.8.x
3648
All of those changes apply to those who extends various parts of this library.
3749
If you only use the library and don't try to extend it - everything should work without breaks.
3850

3951

40-
#### Breaking: Custom directives handling
52+
### Breaking: Custom directives handling
4153
When passing custom directives to schema, default directives (like `@skip` and `@include`)
4254
are not added to schema automatically anymore. If you need them - add them explicitly with
4355
your other directives.
@@ -58,15 +70,15 @@ $schema = new Schema([
5870
]);
5971
```
6072

61-
#### Breaking: Schema protected property and methods visibility
73+
### Breaking: Schema protected property and methods visibility
6274
Most of the `protected` properties and methods of `GraphQL\Schema` were changed to `private`.
6375
Please use public interface instead.
6476

65-
#### Breaking: Node kind constants
77+
### Breaking: Node kind constants
6678
Node kind constants were extracted from `GraphQL\Language\AST\Node` to
6779
separate class `GraphQL\Language\AST\NodeKind`
6880

69-
#### Non-breaking: AST node classes renamed
81+
### Non-breaking: AST node classes renamed
7082
AST node classes were renamed to disambiguate with types. e.g.:
7183

7284
```
@@ -78,7 +90,7 @@ etc.
7890
Old names are still available via `class_alias` defined in `src/deprecated.php`.
7991
This file is included automatically when using composer autoloading.
8092

81-
#### Deprecations
93+
### Deprecations
8294
There are several deprecations which still work, but trigger `E_USER_DEPRECATED` when used.
8395

8496
For example `GraphQL\Executor\Executor::setDefaultResolveFn()` is renamed to `setDefaultResolver()`
@@ -89,7 +101,7 @@ but still works with old name.
89101
There are a few new breaking changes in v0.7.0 that were added to the graphql-js reference implementation
90102
with the spec of April2016
91103

92-
#### 1. Context for resolver
104+
### 1. Context for resolver
93105

94106
You can now pass a custom context to the `GraphQL::execute` function that is available in all resolvers as 3rd argument.
95107
This can for example be used to pass the current user etc.
@@ -147,7 +159,7 @@ function resolveMyField($object, array $args, $context, ResolveInfo $info){
147159
}
148160
```
149161

150-
#### 2. Schema constructor signature
162+
### 2. Schema constructor signature
151163

152164
The signature of the Schema constructor now accepts an associative config array instead of positional arguments:
153165

@@ -165,7 +177,7 @@ $schema = new Schema([
165177
]);
166178
```
167179

168-
#### 3. Types can be directly passed to schema
180+
### 3. Types can be directly passed to schema
169181

170182
There are edge cases when GraphQL cannot infer some types from your schema.
171183
One example is when you define a field of interface type and object types implementing

0 commit comments

Comments
 (0)