diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5cc91e4a0a8..b30314b0762 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -275,8 +275,11 @@ We also build commonjs builds to run in node (for testing with jest or etc.) and
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
+
+
+
Jed Watson 💻 |
@@ -332,7 +335,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
+
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
diff --git a/README.md b/README.md
index cbec8357e61..6fe425ac48b 100644
--- a/README.md
+++ b/README.md
@@ -66,8 +66,11 @@ We'd like to start by thanking all our wonderful contributors:
([emoji key](https://allcontributors.org/docs/en/emoji-key)):
+
+
+
Jed Watson 💻 |
@@ -123,7 +126,9 @@ We'd like to start by thanking all our wonderful contributors:
+
+
### Demo Projects
diff --git a/packages/adapter-mongoose/lib/adapter-mongoose.js b/packages/adapter-mongoose/lib/adapter-mongoose.js
index 2026639be36..40ba2691f4f 100644
--- a/packages/adapter-mongoose/lib/adapter-mongoose.js
+++ b/packages/adapter-mongoose/lib/adapter-mongoose.js
@@ -216,35 +216,27 @@ class MongooseListAdapter extends BaseListAdapter {
args = mergeWhereClause(args, { id: { $in: ids[0][from.fromField] || [] } });
}
}
- function graphQlQueryToMongoJoinQuery(query) {
- const _query = {
- ...query.where,
- ...mapKeyNames(
- // Grab all the modifiers
- pick(query, ['search', 'orderBy', 'skip', 'first']),
- // and prefix with a dollar symbol so they can be picked out by the
- // query builder tokeniser
- key => `$${key}`
- ),
- };
-
- return mapKeys(_query, field => {
- if (getType(field) !== 'Object' || !field.where) {
- return field;
- }
-
- // recurse on object (ie; relationship) types
- return graphQlQueryToMongoJoinQuery(field);
- });
- }
+ // Convert the args `where` clauses and modifiers into a data structure
+ // which can be consumed by the queryParser. Modifiers are prefixed with a
+ // $ symbol (e.g. skip => $skip) to be identified by the tokenizer.
+ // `where` keys are removed, and nested queries are handled recursively.
+ // { where: { a: 'A', b: { where: { c: 'C' } } }, skip: 10 }
+ // => { a: 'A', b: { c: 'C' }, $skip: 10 }
+ const graphQlQueryToMongoJoinQuery = ({ where, ...modifiers }) => ({
+ ...mapKeys(where || {}, whereElement =>
+ getType(whereElement) === 'Object' && whereElement.where
+ ? graphQlQueryToMongoJoinQuery(whereElement) // Recursively traverse relationship fields
+ : whereElement
+ ),
+ ...mapKeyNames(pick(modifiers, ['search', 'orderBy', 'skip', 'first']), key => `$${key}`),
+ });
let query;
try {
query = graphQlQueryToMongoJoinQuery(args);
} catch (error) {
return Promise.reject(error);
}
-
if (meta) {
// Order is important here, which is why we do it last (v8 will append the
// key, and keep them stable)