@envelop/core
Advanced tools
Comparing version 0.4.0-alpha-f2ae2b7.0 to 0.4.0
17
index.js
@@ -20,3 +20,3 @@ 'use strict'; | ||
for (const field of fields) { | ||
const originalFn = field.resolve || graphql.defaultFieldResolver; | ||
let resolverFn = (field.resolve || graphql.defaultFieldResolver); | ||
field.resolve = async (root, args, context, info) => { | ||
@@ -27,7 +27,16 @@ if (context && context[resolversHooksSymbol]) { | ||
for (const hook of hooks) { | ||
const afterFn = await hook({ root, args, context, info }); | ||
const afterFn = await hook({ | ||
root, | ||
args, | ||
context, | ||
info, | ||
resolverFn, | ||
replaceResolverFn: newFn => { | ||
resolverFn = newFn; | ||
}, | ||
}); | ||
afterFn && afterCalls.push(afterFn); | ||
} | ||
try { | ||
let result = await originalFn(root, args, context, info); | ||
let result = await resolverFn(root, args, context, info); | ||
for (const afterFn of afterCalls) { | ||
@@ -57,3 +66,3 @@ afterFn({ | ||
else { | ||
return originalFn(root, args, context, info); | ||
return resolverFn(root, args, context, info); | ||
} | ||
@@ -60,0 +69,0 @@ }; |
{ | ||
"name": "@envelop/core", | ||
"version": "0.4.0-alpha-f2ae2b7.0", | ||
"version": "0.4.0", | ||
"sideEffects": false, | ||
@@ -9,3 +9,3 @@ "peerDependencies": { | ||
"dependencies": { | ||
"@envelop/types": "0.2.1" | ||
"@envelop/types": "0.3.0" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
188040
1702
+ Added@envelop/types@0.3.0(transitive)
- Removed@envelop/types@0.2.1(transitive)
Updated@envelop/types@0.3.0