Skip to content

Commit c6a6388

Browse files
committed
Export default resolver function as defaultResolver
Closes #527
1 parent b93f049 commit c6a6388

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/execution/execute.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ function resolveField(
557557
}
558558

559559
const returnType = fieldDef.type;
560-
const resolveFn = fieldDef.resolve || defaultResolveFn;
560+
const resolveFn = fieldDef.resolve || defaultFieldResolver;
561561

562562
// The resolve function's optional third argument is a context value that
563563
// is provided to every resolve function within an execution. It is commonly
@@ -1017,7 +1017,8 @@ function defaultResolveTypeFn(
10171017
* and returns it as the result, or if it's a function, returns the result
10181018
* of calling that function while passing along args and context.
10191019
*/
1020-
function defaultResolveFn(source: any, args, context, { fieldName }) {
1020+
export const defaultFieldResolver: GraphQLFieldResolveFn<any> =
1021+
function (source, args, context, { fieldName }) {
10211022
// ensure source is a value for which property access is acceptable.
10221023
if (typeof source === 'object' || typeof source === 'function') {
10231024
const property = source[fieldName];
@@ -1026,7 +1027,7 @@ function defaultResolveFn(source: any, args, context, { fieldName }) {
10261027
}
10271028
return property;
10281029
}
1029-
}
1030+
};
10301031

10311032
/**
10321033
* Checks to see if this object acts like a Promise, i.e. has a "then"

src/execution/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
export { execute } from './execute';
10+
export { execute, defaultFieldResolver } from './execute';

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export {
130130
// Execute GraphQL queries.
131131
export {
132132
execute,
133+
defaultFieldResolver,
133134
} from './execution';
134135

135136

0 commit comments

Comments
 (0)