Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,23 @@ const createResult = async ({
}
}

// Execute rootValue functions if present
const executedRootValue = Object.keys(rootValue).reduce((accumulator, rootValueKey) => {
const rootValueValue = rootValue[rootValueKey];
if (typeof rootValueValue === 'function') {
accumulator[rootValueKey] = rootValueValue({}, request);
} else {
accumulator[rootValueKey] = rootValueValue;
}
return accumulator;
}, {});

// Perform the execution, reporting any errors creating the context.
try {
return await execute(
schema,
documentAST,
rootValue,
executedRootValue,
context,
variables,
operationName
Expand Down