diff --git a/README.md b/README.md index deef454..810fa98 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ This repository contains a set of tests to evaluate and compare the compatibilit -| Gateway | Compatibility | Test Cases | Test Suites | -| :-------------------------------------------------------------: | :-----------: | :----------: | :---------: | -| [Hive Gateway](https://the-guild.dev/graphql/hive/docs/gateway) | 100.00% | 🟢 187 | 🟢 41 | -| [Apollo Router](https://www.apollographql.com/) | 97.86% | 🟢 183 ❌ 4 | 🟢 39 ❌ 2 | -| [Apollo Gateway](https://www.apollographql.com/) | 97.33% | 🟢 182 ❌ 5 | 🟢 38 ❌ 3 | -| [Cosmo Router](https://wundergraph.com) | 95.19% | 🟢 178 ❌ 9 | 🟢 36 ❌ 5 | -| [Grafbase Gateway](https://grafbase.com) | 90.91% | 🟢 170 ❌ 17 | 🟢 35 ❌ 6 | -| [Inigo Gateway](https://inigo.io) | 48.66% | 🟢 91 ❌ 96 | 🟢 12 ❌ 29 | +| Gateway | Compatibility | Test Cases | Test Suites | +| :--------------------------------------------------------: | :-----------: | :----------: | :---------: | +| [Hive Gateway](https://the-guild.dev/graphql/hive/gateway) | 98.94% | 🟢 187 ❌ 2 | 🟢 41 ❌ 1 | +| [Apollo Router](https://www.apollographql.com/) | 97.88% | 🟢 185 ❌ 4 | 🟢 40 ❌ 2 | +| [Apollo Gateway](https://www.apollographql.com/) | 97.35% | 🟢 184 ❌ 5 | 🟢 39 ❌ 3 | +| [Cosmo Router](https://wundergraph.com) | 95.24% | 🟢 180 ❌ 9 | 🟢 37 ❌ 5 | +| [Grafbase Gateway](https://grafbase.com) | 91.01% | 🟢 172 ❌ 17 | 🟢 36 ❌ 6 | +| [Inigo Gateway](https://inigo.io) | 48.15% | 🟢 91 ❌ 98 | 🟢 12 ❌ 30 | diff --git a/REPORT.md b/REPORT.md index 33281e3..d698d44 100644 --- a/REPORT.md +++ b/REPORT.md @@ -2,14 +2,14 @@ ## Summary -| Gateway | Compatibility | Test Cases | Test Suites | -| :-------------------------------------------------------------: | :-----------: | :----------: | :---------: | -| [Hive Gateway](https://the-guild.dev/graphql/hive/docs/gateway) | 100.00% | 🟢 187 | 🟢 41 | -| [Apollo Router](https://www.apollographql.com/) | 97.86% | 🟢 183 ❌ 4 | 🟢 39 ❌ 2 | -| [Apollo Gateway](https://www.apollographql.com/) | 97.33% | 🟢 182 ❌ 5 | 🟢 38 ❌ 3 | -| [Cosmo Router](https://wundergraph.com) | 95.19% | 🟢 178 ❌ 9 | 🟢 36 ❌ 5 | -| [Grafbase Gateway](https://grafbase.com) | 90.91% | 🟢 170 ❌ 17 | 🟢 35 ❌ 6 | -| [Inigo Gateway](https://inigo.io) | 48.66% | 🟢 91 ❌ 96 | 🟢 12 ❌ 29 | +| Gateway | Compatibility | Test Cases | Test Suites | +| :--------------------------------------------------------: | :-----------: | :----------: | :---------: | +| [Hive Gateway](https://the-guild.dev/graphql/hive/gateway) | 98.94% | 🟢 187 ❌ 2 | 🟢 41 ❌ 1 | +| [Apollo Router](https://www.apollographql.com/) | 97.88% | 🟢 185 ❌ 4 | 🟢 40 ❌ 2 | +| [Apollo Gateway](https://www.apollographql.com/) | 97.35% | 🟢 184 ❌ 5 | 🟢 39 ❌ 3 | +| [Cosmo Router](https://wundergraph.com) | 95.24% | 🟢 180 ❌ 9 | 🟢 37 ❌ 5 | +| [Grafbase Gateway](https://grafbase.com) | 91.01% | 🟢 172 ❌ 17 | 🟢 36 ❌ 6 | +| [Inigo Gateway](https://inigo.io) | 48.15% | 🟢 91 ❌ 98 | 🟢 12 ❌ 30 | ## Detailed Results @@ -22,7 +22,7 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id ### Hive Gateway - [Repository](https://github.com/graphql-hive/gateway) -- [Website](https://the-guild.dev/graphql/hive/docs/gateway) +- [Website](https://the-guild.dev/graphql/hive/gateway)
Results @@ -80,6 +80,8 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
🟢🟢
provides-on-union
🟢🟢
+requires-circular +
❌❌
requires-interface
🟢🟢🟢🟢🟢
requires-requires @@ -173,6 +175,8 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
🟢🟢
provides-on-union
🟢🟢
+requires-circular +
🟢🟢
requires-interface
🟢🟢🟢🟢🟢
requires-requires @@ -266,6 +270,8 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
🟢🟢
provides-on-union
🟢🟢
+requires-circular +
🟢🟢
requires-interface
🟢🟢🟢🟢🟢
requires-requires @@ -359,6 +365,8 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
❌❌
provides-on-union
❌❌
+requires-circular +
🟢🟢
requires-interface
🟢🟢🟢🟢🟢
requires-requires @@ -452,6 +460,8 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
❌❌
provides-on-union
🟢❌
+requires-circular +
🟢🟢
requires-interface
🟢🟢🟢🟢🟢
requires-requires @@ -545,6 +555,8 @@ You can look at the full list of tests [here](./src/test-suites/). Every test id
❌❌
provides-on-union
❌❌
+requires-circular +
❌❌
requires-interface
❌❌❌❌❌
requires-requires diff --git a/gateways/apollo-gateway/results.txt b/gateways/apollo-gateway/results.txt index e354a06..f718ccf 100644 --- a/gateways/apollo-gateway/results.txt +++ b/gateways/apollo-gateway/results.txt @@ -52,6 +52,8 @@ provides-on-interface .. provides-on-union .. +requires-circular +.. requires-interface ..... requires-requires @@ -82,6 +84,6 @@ union-intersection ............ --- -Total: 187 -Passed: 182 +Total: 189 +Passed: 184 Failed: 5 \ No newline at end of file diff --git a/gateways/apollo-router/results.txt b/gateways/apollo-router/results.txt index c92d430..a348a04 100644 --- a/gateways/apollo-router/results.txt +++ b/gateways/apollo-router/results.txt @@ -52,6 +52,8 @@ provides-on-interface .. provides-on-union .. +requires-circular +.. requires-interface ..... requires-requires @@ -82,6 +84,6 @@ union-intersection ............ --- -Total: 187 -Passed: 183 +Total: 189 +Passed: 185 Failed: 4 \ No newline at end of file diff --git a/gateways/cosmo-router/results.txt b/gateways/cosmo-router/results.txt index 7ede5a3..6fcd3a7 100644 --- a/gateways/cosmo-router/results.txt +++ b/gateways/cosmo-router/results.txt @@ -52,6 +52,8 @@ provides-on-interface XX provides-on-union XX +requires-circular +.. requires-interface ..... requires-requires @@ -82,6 +84,6 @@ union-intersection ............ --- -Total: 187 -Passed: 178 +Total: 189 +Passed: 180 Failed: 9 \ No newline at end of file diff --git a/gateways/grafbase-gateway/results.txt b/gateways/grafbase-gateway/results.txt index 393a196..51b2d9b 100644 --- a/gateways/grafbase-gateway/results.txt +++ b/gateways/grafbase-gateway/results.txt @@ -52,6 +52,8 @@ provides-on-interface XX provides-on-union .X +requires-circular +.. requires-interface ..... requires-requires @@ -82,6 +84,6 @@ union-intersection ........X..X --- -Total: 187 -Passed: 170 +Total: 189 +Passed: 172 Failed: 17 \ No newline at end of file diff --git a/gateways/hive-gateway/gateway.json b/gateways/hive-gateway/gateway.json index 11e64c8..18cb985 100644 --- a/gateways/hive-gateway/gateway.json +++ b/gateways/hive-gateway/gateway.json @@ -1,7 +1,7 @@ { "name": "Hive Gateway", "repository": "https://github.com/graphql-hive/gateway", - "website": "https://the-guild.dev/graphql/hive/docs/gateway", + "website": "https://the-guild.dev/graphql/hive/gateway", "graphql": "http://127.0.0.1:4000/graphql", "health": "http://127.0.0.1:4000/healthcheck" } diff --git a/gateways/hive-gateway/results.txt b/gateways/hive-gateway/results.txt index 4bab9c4..8807208 100644 --- a/gateways/hive-gateway/results.txt +++ b/gateways/hive-gateway/results.txt @@ -52,6 +52,8 @@ provides-on-interface .. provides-on-union .. +requires-circular +XX requires-interface ..... requires-requires @@ -82,6 +84,6 @@ union-intersection ............ --- -Total: 187 +Total: 189 Passed: 187 -Failed: 0 \ No newline at end of file +Failed: 2 \ No newline at end of file diff --git a/gateways/inigo-gateway/results.txt b/gateways/inigo-gateway/results.txt index cc52738..23d418c 100644 --- a/gateways/inigo-gateway/results.txt +++ b/gateways/inigo-gateway/results.txt @@ -52,6 +52,8 @@ provides-on-interface XX provides-on-union XX +requires-circular +XX requires-interface XXXXX requires-requires @@ -82,6 +84,6 @@ union-intersection XXXXXXXXX.XX --- -Total: 187 +Total: 189 Passed: 91 -Failed: 96 \ No newline at end of file +Failed: 98 \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index f33ae70..b97fe8b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,6 +45,7 @@ async function getTestCases(router: ReturnType) { import("./test-suites/requires-with-argument/index.js"), import("./test-suites/keys-mashup/index.js"), import("./test-suites/null-keys/index.js"), + import("./test-suites/requires-circular/index.js"), ].map((i) => i.then((e) => e.default)) ); diff --git a/src/test-suites/requires-circular/a.subgraph.ts b/src/test-suites/requires-circular/a.subgraph.ts new file mode 100644 index 0000000..1e83287 --- /dev/null +++ b/src/test-suites/requires-circular/a.subgraph.ts @@ -0,0 +1,72 @@ +import { createSubgraph } from "../../subgraph.js"; +import { authors, posts } from "./data.js"; + +export default createSubgraph("a", { + typeDefs: /* GraphQL */ ` + extend schema + @link( + url: "https://specs.apollo.dev/federation/v2.3" + import: ["@key", "@external", "@requires"] + ) + + type Query { + feed: [Post] + } + + type Post @key(fields: "id") { + id: ID! + byNovice: Boolean! @external + byExpert: Boolean! @requires(fields: "byNovice") + } + + type Author @key(fields: "id") { + id: ID! + name: String! + yearsOfExperience: Int! + } + `, + resolvers: { + Query: { + feed() { + return posts.map((post) => ({ id: post.id })); + }, + }, + Post: { + __resolveReference(ref: { id: string; byNovice?: boolean }) { + const post = posts.find((post) => post.id === ref.id); + if (!post) { + return null; + } + if (ref.byNovice == null) { + return { + id: post.id, + }; + } + return { + id: post.id, + byNovice: ref.byNovice, + }; + }, + byExpert(post: { byNovice: boolean }) { + if (post.byNovice == null) { + // ensuring requires is not skipped + return null; + } + return !post.byNovice; + }, + }, + Author: { + __resolveReference(ref: { id: string }) { + const author = authors.find((author) => author.id === ref.id); + if (!author) { + return null; + } + return { + id: author.id, + name: author.name, + yearsOfExperience: author.yearsOfExperience, + }; + }, + }, + }, +}); diff --git a/src/test-suites/requires-circular/b.subgraph.ts b/src/test-suites/requires-circular/b.subgraph.ts new file mode 100644 index 0000000..8455a67 --- /dev/null +++ b/src/test-suites/requires-circular/b.subgraph.ts @@ -0,0 +1,46 @@ +import { createSubgraph } from "../../subgraph.js"; +import { posts } from "./data.js"; + +export default createSubgraph("b", { + typeDefs: /* GraphQL */ ` + extend schema + @link( + url: "https://specs.apollo.dev/federation/v2.3" + import: ["@key", "@external", "@requires"] + ) + + type Post @key(fields: "id") { + id: ID! + author: Author! + byNovice: Boolean! @requires(fields: "author { yearsOfExperience }") + } + + type Author @key(fields: "id") { + id: ID! + yearsOfExperience: Int! @external + } + `, + resolvers: { + Post: { + __resolveReference(ref: { + id: string; + author?: { yearsOfExperience: number }; + }) { + const post = posts.find((post) => post.id === ref.id); + if (!post) { + return null; + } + return { + id: post.id, + author: { + id: post.author.id, + ...ref.author, + }, + }; + }, + byNovice(post: { author: { yearsOfExperience: number } }) { + return post.author.yearsOfExperience < 10; + }, + }, + }, +}); diff --git a/src/test-suites/requires-circular/data.ts b/src/test-suites/requires-circular/data.ts new file mode 100644 index 0000000..19841ab --- /dev/null +++ b/src/test-suites/requires-circular/data.ts @@ -0,0 +1,25 @@ +export const authors = [ + { + id: "a1", + name: "John", + yearsOfExperience: 5, + }, + { + id: "a2", + name: "Jane", + yearsOfExperience: 20, + }, +]; + +export const posts = [ + { + id: "p1", + body: "p1-body", + author: authors[0], + }, + { + id: "p2", + body: "p2-body", + author: authors[1], + }, +]; diff --git a/src/test-suites/requires-circular/index.ts b/src/test-suites/requires-circular/index.ts new file mode 100644 index 0000000..e81662f --- /dev/null +++ b/src/test-suites/requires-circular/index.ts @@ -0,0 +1,6 @@ +import { serve } from "../../supergraph.js"; +import a from "./a.subgraph.js"; +import b from "./b.subgraph.js"; +import test from "./test.js"; + +export default serve("requires-circular", [a, b], test); diff --git a/src/test-suites/requires-circular/test.ts b/src/test-suites/requires-circular/test.ts new file mode 100644 index 0000000..5932e75 --- /dev/null +++ b/src/test-suites/requires-circular/test.ts @@ -0,0 +1,46 @@ +import { createTest } from "../../testkit.js"; + +export default [ + createTest( + /* GraphQL */ ` + { + feed { + byNovice + } + } + `, + { + data: { + feed: [ + { + byNovice: true, + }, + { + byNovice: false, + }, + ], + }, + } + ), + createTest( + /* GraphQL */ ` + { + feed { + byExpert + } + } + `, + { + data: { + feed: [ + { + byExpert: false, + }, + { + byExpert: true, + }, + ], + }, + } + ), +]; diff --git a/website/data.json b/website/data.json index 3be3ecf..1814fc5 100644 --- a/website/data.json +++ b/website/data.json @@ -2,79 +2,79 @@ { "name": "Hive Gateway", "cases": { - "total": 187, + "total": 189, "passed": 187, - "failed": 0 + "failed": 2 }, "suites": { - "total": 41, + "total": 42, "passed": 41, - "failed": 0 + "failed": 1 } }, { "name": "Apollo Router", "cases": { - "total": 187, - "passed": 183, + "total": 189, + "passed": 185, "failed": 4 }, "suites": { - "total": 41, - "passed": 39, + "total": 42, + "passed": 40, "failed": 2 } }, { "name": "Apollo Gateway", "cases": { - "total": 187, - "passed": 182, + "total": 189, + "passed": 184, "failed": 5 }, "suites": { - "total": 41, - "passed": 38, + "total": 42, + "passed": 39, "failed": 3 } }, { "name": "Cosmo Router", "cases": { - "total": 187, - "passed": 178, + "total": 189, + "passed": 180, "failed": 9 }, "suites": { - "total": 41, - "passed": 36, + "total": 42, + "passed": 37, "failed": 5 } }, { "name": "Grafbase Gateway", "cases": { - "total": 187, - "passed": 170, + "total": 189, + "passed": 172, "failed": 17 }, "suites": { - "total": 41, - "passed": 35, + "total": 42, + "passed": 36, "failed": 6 } }, { "name": "Inigo Gateway", "cases": { - "total": 187, + "total": 189, "passed": 91, - "failed": 96 + "failed": 98 }, "suites": { - "total": 41, + "total": 42, "passed": 12, - "failed": 29 + "failed": 30 } } ] \ No newline at end of file diff --git a/website/index.html b/website/index.html index 7da326a..77d01cd 100644 --- a/website/index.html +++ b/website/index.html @@ -230,22 +230,24 @@

Hive Gateway - 100.00% + 98.94% ✓ 187 + ✗ 2 ✓ 41 + ✗ 1 Apollo Router - 97.86% + 97.88% - ✓ 183 + ✓ 185 ✗ 4 - ✓ 39 + ✓ 40 ✗ 2 @@ -298,13 +300,13 @@

Apollo Gateway - 97.33% + 97.35% - ✓ 182 + ✓ 184 ✗ 5 - ✓ 38 + ✓ 39 ✗ 3 @@ -328,13 +330,13 @@

Cosmo Router - 95.19% + 95.24% - ✓ 178 + ✓ 180 ✗ 9 - ✓ 36 + ✓ 37 ✗ 5 @@ -358,13 +360,13 @@

Grafbase Gateway - 90.91% + 91.01% - ✓ 170 + ✓ 172 ✗ 17 - ✓ 35 + ✓ 36 ✗ 6 @@ -388,14 +390,14 @@

Inigo Gateway - 48.66% + 48.15% ✓ 91 - ✗ 96 + ✗ 98 ✓ 12 - ✗ 29 + ✗ 30 We built this audit for two main reasons. First, as maintainers of Hive Gateway @@ -546,7 +548,7 @@

> (now Hive Gateway) and @@ -596,7 +598,7 @@

  • Hive GatewayMIT License