Skip to content

Commit

Permalink
Only return union members which have fragments in the selection set (#…
Browse files Browse the repository at this point in the history
…289)

* Missing copyright headers

* Point to prerelease documentation for 2.0.0 branch

* General housekeeping before release

* Update code comment

* Fix TCK tests broken from merge

* Add scalars earlier in schema augmentation for use in types and interfaces without throwing Error (fixes DateTime relationship properties)

* Changes to accomodate merge from master

* Only return union members of which a fragment is present in the selection set

* Fix test broken from merge
  • Loading branch information
darrellwarde authored Jul 5, 2021
1 parent da6e96a commit 982a099
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function createConnectionAndParams({
const unionSubqueries: string[] = [];

unionNodes.forEach((n) => {
if (!node?.fieldsByTypeName[n.name]) {
return;
}

const relatedNodeVariable = `${nodeVariable}_${n.name}`;
const nodeOutStr = `(${relatedNodeVariable}:${n.name})`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ describe("Connections -> Unions", () => {
title: "Oliver Twist",
},
},
{
words: 3413,
node: {},
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,51 @@ RETURN this { .name, publicationsConnection } as this
```

---

### Projecting only one member of union node and relationship properties with no arguments

**GraphQL input**

```graphql
query {
authors {
name
publicationsConnection {
edges {
words
node {
... on Book {
title
}
}
}
}
}
}
```

**Expected Cypher output**

```cypher
MATCH (this:Author)
CALL {
WITH this
CALL {
WITH this
OPTIONAL MATCH (this)-[this_wrote:WROTE]->(this_Book:Book)
WITH { words: this_wrote.words, node: { __resolveType: "Book", title: this_Book.title } } AS edge
RETURN edge
}
WITH collect(edge) as edges, count(edge) as totalCount
RETURN { edges: edges, totalCount: totalCount } AS publicationsConnection
}
RETURN this { .name, publicationsConnection } as this
```

**Expected Cypher params**

```cypher-params
{}
```

---

0 comments on commit 982a099

Please sign in to comment.