Skip to content

Commit

Permalink
Oops - introduced an error in the last release
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyarmes committed Jan 29, 2021
1 parent c0fe9b5 commit 4e2c392
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apongo",
"version": "2.0.1",
"version": "2.0.2",
"description": "Create Mongo aggregation pipelines with recursive joins for Apollo queries.",
"main": "index.js",
"keywords": [
Expand Down
9 changes: 5 additions & 4 deletions src/create-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ function fillPipeline(fields, pipeline, context, path = '') {
}

const fieldsByTypeNameKeys = Object.keys(field.fieldsByTypeName);
if (fieldsByTypeNameKeys.length === 0) return;
if (fieldsByTypeNameKeys.length > 1) throw new ApolloError(`Unable to handle join return type with multiple types (${fieldsByTypeNameKeys.join(', ')})`);
const subFields = field.fieldsByTypeName[fieldsByTypeNameKeys[0]];
fillPipeline(subFields, pipeline, context, `${path}${alias}.`);
if (fieldsByTypeNameKeys.length > 0) {
if (fieldsByTypeNameKeys.length > 1) throw new ApolloError(`Unable to handle join return type with multiple types (${fieldsByTypeNameKeys.join(', ')})`);
const subFields = field.fieldsByTypeName[fieldsByTypeNameKeys[0]];
fillPipeline(subFields, pipeline, context, `${path}${alias}.`);
}

// If the parent didn't exist at all before compose or expr was called then we'll end up with an empty object.
// If that's the case then we remove it.
Expand Down

0 comments on commit 4e2c392

Please sign in to comment.