Skip to content

Commit

Permalink
Shared root but nested (#77)
Browse files Browse the repository at this point in the history
Taken from ardatan/graphql-tools#6620

In case of a shared root field, the gateway should extract available
selection set (nestedly) for each subgraph correctly, then merge deeply
the results.

Blocked by graphql-hive/console#5856

---------

Co-authored-by: Kamil Kisiela <[email protected]>
  • Loading branch information
ardatan and kamilkisiela authored Oct 31, 2024
1 parent f2a0950 commit 246d86a
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This repository contains a set of tests to evaluate and compare the compatibilit
| [Apollo Router](https://www.apollographql.com/) | 97.66% | 🟢 167 ❌ 4 | 🟢 39 ❌ 2 |
| [Apollo Gateway](https://www.apollographql.com/) | 97.08% | 🟢 166 ❌ 5 | 🟢 38 ❌ 3 |
| [Cosmo Router](https://wundergraph.com) | 72.51% | 🟢 124 ❌ 47 | 🟢 19 ❌ 22 |
| [Grafbase Gateway](https://grafbase.com) | 60.23% | 🟢 10368 | 🟢 19 ❌ 22 |
| [Grafbase Gateway](https://grafbase.com) | 59.65% | 🟢 10269 | 🟢 19 ❌ 22 |

<!-- gateways:end -->

Expand Down
6 changes: 3 additions & 3 deletions REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| [Apollo Router](https://www.apollographql.com/) | 97.66% | 🟢 167 ❌ 4 | 🟢 39 ❌ 2 |
| [Apollo Gateway](https://www.apollographql.com/) | 97.08% | 🟢 166 ❌ 5 | 🟢 38 ❌ 3 |
| [Cosmo Router](https://wundergraph.com) | 72.51% | 🟢 124 ❌ 47 | 🟢 19 ❌ 22 |
| [Grafbase Gateway](https://grafbase.com) | 60.23% | 🟢 10368 | 🟢 19 ❌ 22 |
| [Grafbase Gateway](https://grafbase.com) | 59.65% | 🟢 10269 | 🟢 19 ❌ 22 |

## Detailed Results

Expand Down Expand Up @@ -424,7 +424,7 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
<a href="./src/test-suites/input-object-intersection">input-object-intersection</a>
<pre>🟢🟢🟢</pre>
<a href="./src/test-suites/interface-object-with-requires">interface-object-with-requires</a>
<pre>🟢🟢❌🟢❌❌❌</pre>
<pre>🟢❌🟢❌❌❌</pre>
<a href="./src/test-suites/keys-mashup">keys-mashup</a>
<pre>🟢</pre>
<a href="./src/test-suites/mutations">mutations</a>
Expand Down Expand Up @@ -478,5 +478,5 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
<a href="./src/test-suites/union-interface-distributed">union-interface-distributed</a>
<pre>🟢🟢🟢🟢🟢🟢🟢</pre>
<a href="./src/test-suites/union-intersection">union-intersection</a>
<pre>❌🟢🟢❌❌🟢🟢❌</pre>
<pre>🟢🟢🟢❌❌🟢❌</pre>
</details>
1 change: 1 addition & 0 deletions gateways/apollo-router/install.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# https://github.com/apollographql/router/releases
curl -sSL https://router.apollo.dev/download/nix/v1.57.0 | sh
2 changes: 1 addition & 1 deletion gateways/cosmo-router/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -u

BINARY_DOWNLOAD_PREFIX="https://github.com/wundergraph/cosmo/releases/download"

DOWNLOAD_VERSION="0.132.0"
DOWNLOAD_VERSION="0.135.0"

download_binary() {
downloader --check
Expand Down
8 changes: 4 additions & 4 deletions gateways/grafbase-gateway/results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ XXXX
input-object-intersection
...
interface-object-with-requires
..X.XXX
X.X.XXX
keys-mashup
.
mutations
Expand Down Expand Up @@ -79,9 +79,9 @@ unavailable-override
union-interface-distributed
.......
union-intersection
X..XX..X
...XX.XX

---
Total: 171
Passed: 103
Failed: 68
Passed: 102
Failed: 69
2 changes: 1 addition & 1 deletion gateways/hive-gateway/install.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
curl -sSL https://graphql-hive.com/install-gateway.sh | sh -s "1.4.0"
curl -sSL https://graphql-hive.com/install-gateway.sh | sh -s "1.4.3"
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@
},
"devDependencies": {
"@apollo/gateway": "2.9.3",
"@apollo/server": "4.11.0",
"@apollo/server": "4.11.2",
"@types/async-retry": "1.4.9",
"@types/express": "5.0.0",
"@types/node": "22.8.1",
"@types/node": "22.8.5",
"@types/wait-on": "5.3.4",
"@types/yargs": "17.0.33",
"@types/detect-port": "1.3.5",
"express": "5.0.1",
"prettier": "3.3.3",
"tsx": "4.19.2",
"typescript": "5.6.3",
"wgc": "0.68.6"
"wgc": "0.69.1"
}
}
11 changes: 8 additions & 3 deletions src/test-suites/shared-root/category.subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ export default createSubgraph("category", {
)
type Query {
product: Product @shareable
products: [Product] @shareable
product: Product! @shareable
products: [Product!]! @shareable
}
type Product {
id: ID! @shareable
category: String @shareable
category: Category!
}
type Category {
id: ID!
name: String!
}
`,
resolvers: {
Expand Down
22 changes: 19 additions & 3 deletions src/test-suites/shared-root/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
export const product = {
id: "1",
name: "Product 1",
category: "Category 1",
price: 100,
name: {
id: "1",
brand: "Brand 1",
model: "Model 1",
},
category: {
id: "1",
name: "Category 1",
},
price: {
id: "1",
amount: 1000,
currency: "USD",
},
address: {
id: "1",
street: "123 Main St",
city: "Springfield",
}
};
12 changes: 9 additions & 3 deletions src/test-suites/shared-root/name.subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ export default createSubgraph("name", {
)
type Query {
product: Product @shareable
products: [Product] @shareable
product: Product! @shareable
products: [Product!]! @shareable
}
type Product {
id: ID! @shareable
name: String @shareable
name: Name!
}
type Name {
id: ID!
brand: String!
model: String!
}
`,
resolvers: {
Expand Down
12 changes: 9 additions & 3 deletions src/test-suites/shared-root/price.subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ export default createSubgraph("price", {
)
type Query {
product: Product @shareable
products: [Product] @shareable
product: Product! @shareable
products: [Product!]! @shareable
}
type Product {
id: ID! @shareable
price: Float @shareable
price: Price!
}
type Price {
id: ID!
amount: Int!
currency: String!
}
`,
resolvers: {
Expand Down
Loading

0 comments on commit 246d86a

Please sign in to comment.