Skip to content

Commit a8089e3

Browse files
committed
use separate supergraphl for tests
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
1 parent 3207897 commit a8089e3

5 files changed

+118
-6
lines changed

apollo-router/src/plugins/cache/snapshots/apollo_router__plugins__cache__tests__insert_with_requires-5.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ expression: cache_keys
44
---
55
[
66
{
7-
"key": "version:1.0:subgraph:inventory:type:Product:entity:4911f7a9dbad8a47b8900d65547503a2f3c0359f65c0bc5652ad9b9843281f66:representation:7ae1cf67d5c484b3430662edab68bf613043333264470c8f5834fea277b4e060:hash:1fc91476195815f017c84a9366856ce8b6ac3fc1770350448d8b283bd9f1e5fd:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c",
7+
"key": "version:1.0:subgraph:inventory:type:Product:entity:4911f7a9dbad8a47b8900d65547503a2f3c0359f65c0bc5652ad9b9843281f66:representation:7ae1cf67d5c484b3430662edab68bf613043333264470c8f5834fea277b4e060:hash:a7b76558fe61b2f89ee9ea8bac8eee0b702ba1f319eaace576ab6ccdd19cdc80:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c",
88
"status": "cached",
99
"cache_control": "public"
1010
},

apollo-router/src/plugins/cache/snapshots/apollo_router__plugins__cache__tests__insert_with_requires.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ expression: cache_keys
44
---
55
[
66
{
7-
"key": "version:1.0:subgraph:inventory:type:Product:entity:4911f7a9dbad8a47b8900d65547503a2f3c0359f65c0bc5652ad9b9843281f66:representation:7ae1cf67d5c484b3430662edab68bf613043333264470c8f5834fea277b4e060:hash:1fc91476195815f017c84a9366856ce8b6ac3fc1770350448d8b283bd9f1e5fd:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c",
7+
"key": "version:1.0:subgraph:inventory:type:Product:entity:4911f7a9dbad8a47b8900d65547503a2f3c0359f65c0bc5652ad9b9843281f66:representation:7ae1cf67d5c484b3430662edab68bf613043333264470c8f5834fea277b4e060:hash:a7b76558fe61b2f89ee9ea8bac8eee0b702ba1f319eaace576ab6ccdd19cdc80:data:d9d84a3c7ffc27b0190a671212f3740e5b8478e84e23825830e97822e25cf05c",
88
"status": "new",
99
"cache_control": "public"
1010
},

apollo-router/src/plugins/cache/tests.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::services::supergraph;
3030

3131
pub(super) const SCHEMA: &str = include_str!("../../testdata/orga_supergraph.graphql");
3232
const SCHEMA_REQUIRES: &str = include_str!("../../testdata/supergraph.graphql");
33+
const SCHEMA_SEVERAL_KEY: &str = include_str!("../../testdata/supergraph_several_key.graphql");
3334
#[derive(Debug)]
3435
pub(crate) struct MockStore {
3536
map: Arc<Mutex<HashMap<Bytes, Bytes>>>,
@@ -407,7 +408,7 @@ async fn insert_with_requires() {
407408
#[tokio::test]
408409
async fn insert_with_several_key_directives() {
409410
let valid_schema =
410-
Arc::new(Schema::parse_and_validate(SCHEMA_REQUIRES, "test.graphql").unwrap());
411+
Arc::new(Schema::parse_and_validate(SCHEMA_SEVERAL_KEY, "test.graphql").unwrap());
411412
let query = "query { topProducts { shippingEstimate price } }";
412413

413414
let subgraphs = MockedSubgraphs([
@@ -475,7 +476,7 @@ async fn insert_with_several_key_directives() {
475476
let service = TestHarness::builder()
476477
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
477478
.unwrap()
478-
.schema(SCHEMA_REQUIRES)
479+
.schema(SCHEMA_SEVERAL_KEY)
479480
.extra_plugin(entity_cache)
480481
.extra_plugin(subgraphs)
481482
.build_supergraph()
@@ -507,7 +508,7 @@ async fn insert_with_several_key_directives() {
507508
let service = TestHarness::builder()
508509
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
509510
.unwrap()
510-
.schema(SCHEMA_REQUIRES)
511+
.schema(SCHEMA_SEVERAL_KEY)
511512
.extra_plugin(entity_cache)
512513
.build_supergraph()
513514
.await

apollo-router/src/testdata/supergraph.graphql

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ enum link__Purpose {
6868

6969
type Product
7070
@join__type(graph: INVENTORY, key: "upc")
71-
@join__type(graph: INVENTORY, key: "upc inStock")
7271
@join__type(graph: PRODUCTS, key: "upc")
7372
@join__type(graph: REVIEWS, key: "upc") {
7473
upc: String!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
schema
2+
@link(url: "https://specs.apollo.dev/link/v1.0")
3+
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) {
4+
query: Query
5+
}
6+
7+
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
8+
9+
directive @join__field(
10+
graph: join__Graph
11+
requires: join__FieldSet
12+
provides: join__FieldSet
13+
type: String
14+
external: Boolean
15+
override: String
16+
usedOverridden: Boolean
17+
) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
18+
19+
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
20+
21+
directive @join__implements(
22+
graph: join__Graph!
23+
interface: String!
24+
) repeatable on OBJECT | INTERFACE
25+
26+
directive @join__type(
27+
graph: join__Graph!
28+
key: join__FieldSet
29+
extension: Boolean! = false
30+
resolvable: Boolean! = true
31+
isInterfaceObject: Boolean! = false
32+
) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
33+
34+
directive @join__unionMember(
35+
graph: join__Graph!
36+
member: String!
37+
) repeatable on UNION
38+
39+
directive @link(
40+
url: String
41+
as: String
42+
for: link__Purpose
43+
import: [link__Import]
44+
) repeatable on SCHEMA
45+
46+
scalar join__FieldSet
47+
48+
enum join__Graph {
49+
ACCOUNTS
50+
@join__graph(name: "accounts", url: "https://accounts.demo.starstuff.dev/")
51+
INVENTORY
52+
@join__graph(
53+
name: "inventory"
54+
url: "https://inventory.demo.starstuff.dev/"
55+
)
56+
PRODUCTS
57+
@join__graph(name: "products", url: "https://products.demo.starstuff.dev/")
58+
REVIEWS
59+
@join__graph(name: "reviews", url: "https://reviews.demo.starstuff.dev/")
60+
}
61+
62+
scalar link__Import
63+
64+
enum link__Purpose {
65+
SECURITY
66+
EXECUTION
67+
}
68+
69+
type Product
70+
@join__type(graph: INVENTORY, key: "upc")
71+
@join__type(graph: INVENTORY, key: "upc inStock")
72+
@join__type(graph: PRODUCTS, key: "upc")
73+
@join__type(graph: REVIEWS, key: "upc") {
74+
upc: String!
75+
weight: Int
76+
@join__field(graph: INVENTORY, external: true)
77+
@join__field(graph: PRODUCTS)
78+
price: Int
79+
@join__field(graph: INVENTORY, external: true)
80+
@join__field(graph: PRODUCTS)
81+
inStock: Boolean @join__field(graph: INVENTORY)
82+
shippingEstimate: Int @join__field(graph: INVENTORY, requires: "price weight")
83+
name: String @join__field(graph: PRODUCTS)
84+
reviews: [Review] @join__field(graph: REVIEWS)
85+
}
86+
87+
type Query
88+
@join__type(graph: ACCOUNTS)
89+
@join__type(graph: INVENTORY)
90+
@join__type(graph: PRODUCTS)
91+
@join__type(graph: REVIEWS) {
92+
me: User @join__field(graph: ACCOUNTS)
93+
topProducts(first: Int = 5): [Product] @join__field(graph: PRODUCTS)
94+
}
95+
96+
type Review @join__type(graph: REVIEWS, key: "id") {
97+
id: ID!
98+
body: String
99+
author: User @join__field(graph: REVIEWS, provides: "username")
100+
product: Product @join__field(graph: REVIEWS)
101+
}
102+
103+
type User
104+
@join__type(graph: ACCOUNTS, key: "id")
105+
@join__type(graph: REVIEWS, key: "id") {
106+
id: ID!
107+
name: String @join__field(graph: ACCOUNTS)
108+
username: String
109+
@join__field(graph: ACCOUNTS)
110+
@join__field(graph: REVIEWS, external: true)
111+
reviews: [Review] @join__field(graph: REVIEWS)
112+
}

0 commit comments

Comments
 (0)