Skip to content
Merged
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
12 changes: 6 additions & 6 deletions src/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function resolveMiddlewareWrapper(resolve = defaultResolveFn, directives = {}) {
* Scanning the shema and wrapping the resolve of each field with the support
* of the graphql custom directives resolve execution
*/
function wrapFieldsWithMiddleware(type, typeMet = {}) {
function wrapFieldsWithMiddleware(type, deepWrap = true, typeMet = {}) {
if(!type){
return;
}
Expand All @@ -106,10 +106,10 @@ function wrapFieldsWithMiddleware(type, typeMet = {}) {
if (field && !typeMet[field.type.name]) {
if (!!field && typeof field == 'object') {
field.resolve = resolveMiddlewareWrapper(field.resolve, field.directives);
if (field.type._fields) {
wrapFieldsWithMiddleware(field.type, typeMet)
} else if (field.type.ofType && field.type.ofType._fields) {
wrapFieldsWithMiddleware(field.type.ofType, typeMet);
if (field.type._fields && deepWrap) {
wrapFieldsWithMiddleware(field.type, deepWrap, typeMet)
} else if (field.type.ofType && field.type.ofType._fields && deepWrap) {
wrapFieldsWithMiddleware(field.type.ofType, deepWrap, typeMet);
}
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@ exports.applySchemaCustomDirectives = function (schema) {
}

wrapFieldsWithMiddleware(schema._queryType);
wrapFieldsWithMiddleware(schema._mutationType);
wrapFieldsWithMiddleware(schema._mutationType, false);

return true;
};