diff --git a/src/execution/execute.js b/src/execution/execute.js index 4358d6a844..3e0218b2fe 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -557,7 +557,7 @@ function resolveField( } const returnType = fieldDef.type; - const resolveFn = fieldDef.resolve || defaultResolveFn; + const resolveFn = fieldDef.resolve || defaultFieldResolver; // The resolve function's optional third argument is a context value that // is provided to every resolve function within an execution. It is commonly @@ -1017,7 +1017,8 @@ function defaultResolveTypeFn( * and returns it as the result, or if it's a function, returns the result * of calling that function while passing along args and context. */ -function defaultResolveFn(source: any, args, context, { fieldName }) { +export const defaultFieldResolver: GraphQLFieldResolveFn = +function (source, args, context, { fieldName }) { // ensure source is a value for which property access is acceptable. if (typeof source === 'object' || typeof source === 'function') { const property = source[fieldName]; @@ -1026,7 +1027,7 @@ function defaultResolveFn(source: any, args, context, { fieldName }) { } return property; } -} +}; /** * Checks to see if this object acts like a Promise, i.e. has a "then" diff --git a/src/execution/index.js b/src/execution/index.js index b1158009ef..03d3f5129f 100644 --- a/src/execution/index.js +++ b/src/execution/index.js @@ -7,4 +7,4 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -export { execute } from './execute'; +export { execute, defaultFieldResolver } from './execute'; diff --git a/src/index.js b/src/index.js index 560dc4b891..c68ca4ed9d 100644 --- a/src/index.js +++ b/src/index.js @@ -130,6 +130,7 @@ export { // Execute GraphQL queries. export { execute, + defaultFieldResolver, } from './execution';