You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,7 +186,7 @@ Option | Type | Notes
186
186
name | `string` | Required. Unique name of this interface type within Schema
187
187
fields | `array` | Required. List of fields required to be defined by interface implementors. See [Fields](#fields) section for available options.
188
188
description | `string` | Textual description of this interface for clients
189
-
resolveType | `callback(value) => objectType` | Any `callable` that receives data from data layer of your application and returns concrete interface implementor for that data.
189
+
resolveType | `callback($value, $context, ResolveInfo $info) => objectType` | Any `callable` that receives data from data layer of your application and returns concrete interface implementor for that data.
190
190
191
191
192
192
**Notes**:
@@ -254,7 +254,7 @@ name | `string` | Required. Unique name of this object type within Schema
254
254
fields | `array` | Required. List of fields describing object properties. See [Fields](#Fields) section for available options.
255
255
description | `string` | Textual description of this type for clients
256
256
interfaces | `array` or `callback() => ObjectType[]` | List of interfaces implemented by this type (or callback returning list of interfaces)
257
-
isTypeOf | `callback($value, GraphQL\Type\Definition\ResolveInfo $info)` | Callback that takes `$value` provided by your data layer and returns true if that `$value` qualifies for this type
257
+
isTypeOf | `callback($value, $context, GraphQL\Type\Definition\ResolveInfo $info)` | Callback that takes `$value` provided by your data layer and returns true if that `$value` qualifies for this type
2. Object types are responsible for data fetching. Each of their fields may have optional `resolve` callback option. This callback takes `$value` that corresponds to instance of this type and returns `data` accepted by type of given field.
264
264
If `resolve` option is not set, GraphQL will try to get `data` from `$value[$fieldName]`.
265
265
266
-
3.`resolve` callback is a place where you can use your existing data fetching logic.
266
+
3.`resolve` callback is a place where you can use your existing data fetching logic.`$context` is defined by your application on the top level of query execution (useful for storing current user, environment details, etc)
267
267
268
268
4. Other `ObjectType` mentioned in examples is `Droid`. Check out tests for this type: https://github.com/webonyx/graphql-php/blob/master/tests/StarWarsSchema.php
269
269
@@ -282,7 +282,7 @@ Option | Type | Notes
282
282
name | `string` | Required. Name of the field. If not set - GraphQL will look use `key` of fields array on type definition.
283
283
type | `Type` or `callback() => Type` | Required. One of internal or custom types. Alternatively - callback that returns `type`.
284
284
args | `array` | Array of possible type arguments. Each entry is expected to be an array with following keys: **name** (`string`), **type** (`Type` or `callback() => Type`), **defaultValue** (`any`)
285
-
resolve | `callback($value, $args, ResolveInfo $info) => $fieldValue` | Function that receives `$value` of parent type and returns value for this field.
285
+
resolve | `callback($value, $args, $context, ResolveInfo $info) => $fieldValue` | Function that receives `$value` of parent type and returns value for this field.`$context` is also defined by your application in the root call to `GraphQL::execute()`
286
286
description | `string` | Field description for clients
287
287
deprecationReason | `string` | Text describing why this field is deprecated. When not empty - field will not be returned by introspection queries (unless forced)
288
288
@@ -461,7 +461,7 @@ try {
461
461
$schema,
462
462
$requestString,
463
463
/* $rootValue */ null,
464
-
/* $context */ null, // A custom context that can be used to pass current User object etc to resolvers.
464
+
/* $context */ null, // A custom context that can be used to pass current User object etc to all resolvers.
0 commit comments