Skip to content

Commit 2af79fd

Browse files
committed
add skipNullKeys
1 parent 7f0e2e2 commit 2af79fd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/service.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,17 @@ module.exports = function (mixinOptions) {
235235
});
236236
} else {
237237
const params = {};
238+
let hasRootKeyValue = false;
238239
if (root && rootKeys) {
239240
rootKeys.forEach(key => {
240-
_.set(params, rootParams[key], _.get(root, key));
241+
const v = _.get(root, key);
242+
_.set(params, rootParams[key], v);
243+
if (v != null) hasRootKeyValue = true;
241244
});
245+
246+
if (def.skipNullKeys && !hasRootKeyValue) {
247+
return null;
248+
}
242249
}
243250

244251
let mergedParams = _.defaultsDeep({}, args, params, staticParams);

0 commit comments

Comments
 (0)