11# Upgrade
22
33## Upgrade v0.9.x > v0.10.x
4- ### Deprecated: GraphQL\Utils moved to GraphQL\Utils\Utils
5- Old class still exists, but triggers deprecation warning.
4+ #### Breaking: default error formatting
5+ By default exceptions thrown in resolvers will be reported with generic message ` "Internal server error" ` .
6+ Only exceptions implementing interface ` GraphQL\Error\ClientAware ` and claiming themselves as ` safe ` will
7+ be reported with full error message.
8+
9+ This is done to avoid information leak in production when unhandled exceptions occur in resolvers
10+ (e.g. database connection errors, file access errors, etc).
11+
12+ During development or debugging use ` $executionResult->toArray(true) ` . It will add ` debugMessage ` key to
13+ each error entry in result. If you also want to add ` trace ` for each error - pass flags instead:
14+
15+ ```
16+ use GraphQL\Error\FormattedError;
17+ $debug = FormattedError::INCLUDE_DEBUG_MESSAGE | FormattedError::INCLUDE_TRACE;
18+ $result = GraphQL::executeAndReturnResult()->toArray($debug);
19+ ```
20+
21+ To change default ` "Internal server error" ` message to something else, use:
22+ ```
23+ GraphQL\Error\FormattedError::setInternalErrorMessage("Unexpected error");
24+ ```
25+
26+ ** This change only affects default error reporting mechanism. If you set your own error formatter using
27+ ` ExecutionResult::setErrorFormatter() ` you won't be affected by this change.**
28+
29+ If you are not happy with this change just set [ your own error
30+ formatter] ( http://webonyx.github.io/graphql-php/error-handling/#custom-error-formatting ) .
31+
32+ #### Deprecated: GraphQL\Utils moved to GraphQL\Utils\Utils
33+ Old class still exists, but triggers deprecation warning when referenced.
634
735## Upgrade v0.7.x > v0.8.x
836All of those changes apply to those who extends various parts of this library.
937If you only use the library and don't try to extend it - everything should work without breaks.
1038
1139
12- ### Breaking: Custom directives handling
40+ #### Breaking: Custom directives handling
1341When passing custom directives to schema, default directives (like ` @skip ` and ` @include ` )
1442are not added to schema automatically anymore. If you need them - add them explicitly with
1543your other directives.
@@ -30,15 +58,15 @@ $schema = new Schema([
3058]);
3159```
3260
33- ### Breaking: Schema protected property and methods visibility
61+ #### Breaking: Schema protected property and methods visibility
3462Most of the ` protected ` properties and methods of ` GraphQL\Schema ` were changed to ` private ` .
3563Please use public interface instead.
3664
37- ### Breaking: Node kind constants
65+ #### Breaking: Node kind constants
3866Node kind constants were extracted from ` GraphQL\Language\AST\Node ` to
3967separate class ` GraphQL\Language\AST\NodeKind `
4068
41- ### Non-breaking: AST node classes renamed
69+ #### Non-breaking: AST node classes renamed
4270AST node classes were renamed to disambiguate with types. e.g.:
4371
4472```
5078Old names are still available via ` class_alias ` defined in ` src/deprecated.php ` .
5179This file is included automatically when using composer autoloading.
5280
53- ### Deprecations
81+ #### Deprecations
5482There are several deprecations which still work, but trigger ` E_USER_DEPRECATED ` when used.
5583
5684For example ` GraphQL\Executor\Executor::setDefaultResolveFn() ` is renamed to ` setDefaultResolver() `
@@ -61,7 +89,7 @@ but still works with old name.
6189There are a few new breaking changes in v0.7.0 that were added to the graphql-js reference implementation
6290with the spec of April2016
6391
64- ### 1. Context for resolver
92+ #### 1. Context for resolver
6593
6694You can now pass a custom context to the ` GraphQL::execute ` function that is available in all resolvers as 3rd argument.
6795This can for example be used to pass the current user etc.
@@ -119,7 +147,7 @@ function resolveMyField($object, array $args, $context, ResolveInfo $info){
119147}
120148```
121149
122- ### 2. Schema constructor signature
150+ #### 2. Schema constructor signature
123151
124152The signature of the Schema constructor now accepts an associative config array instead of positional arguments:
125153
@@ -137,7 +165,7 @@ $schema = new Schema([
137165]);
138166```
139167
140- ### 3. Types can be directly passed to schema
168+ #### 3. Types can be directly passed to schema
141169
142170There are edge cases when GraphQL cannot infer some types from your schema.
143171One example is when you define a field of interface type and object types implementing
0 commit comments