Skip to content

Commit fc7c390

Browse files
authored
Mention default resolvers
1 parent 73b3654 commit fc7c390

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

site/graphql-js/APIReference-TypeSystem.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ type GraphQLInterfacesThunk = () => Array<GraphQLInterfaceType>;
255255

256256
type GraphQLFieldConfigMapThunk = () => GraphQLFieldConfigMap;
257257

258+
// See below about resolver functions.
258259
type GraphQLFieldResolveFn = (
259260
source?: any,
260261
args?: {[argName: string]: any},
@@ -304,6 +305,12 @@ When two types need to refer to each other, or a type needs to refer to
304305
itself in a field, you can use a function expression (aka a closure or a
305306
thunk) to supply the fields lazily.
306307
308+
Note that resolver functions are provided the `source` object as the first parameter.
309+
However, if a resolver function is not provided, then the default resolver is
310+
used, which looks for a method on `source` of the same name as the field. If found,
311+
the method is called with `(args, context, info)`. Since it is a method on `source`,
312+
that value can always be referenced with `this`.
313+
307314
#### Examples
308315
309316
```js

0 commit comments

Comments
 (0)