Skip to content

Commit dd05ef4

Browse files
committed
try
1 parent 4fc5ad6 commit dd05ef4

File tree

10 files changed

+431
-54
lines changed

10 files changed

+431
-54
lines changed
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
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+
@link(url: "https://specs.apollo.dev/inaccessible/v0.2", for: SECURITY) {
5+
query: Query
6+
}
7+
8+
directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
9+
10+
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
11+
12+
directive @join__field(
13+
graph: join__Graph
14+
requires: join__FieldSet
15+
provides: join__FieldSet
16+
type: String
17+
external: Boolean
18+
override: String
19+
usedOverridden: Boolean
20+
) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
21+
22+
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
23+
24+
directive @join__implements(
25+
graph: join__Graph!
26+
interface: String!
27+
) repeatable on OBJECT | INTERFACE
28+
29+
directive @join__type(
30+
graph: join__Graph!
31+
key: join__FieldSet
32+
extension: Boolean! = false
33+
resolvable: Boolean! = true
34+
isInterfaceObject: Boolean! = false
35+
) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
36+
37+
directive @join__unionMember(
38+
graph: join__Graph!
39+
member: String!
40+
) repeatable on UNION
41+
42+
directive @link(
43+
url: String
44+
as: String
45+
for: link__Purpose
46+
import: [link__Import]
47+
) repeatable on SCHEMA
48+
49+
type Agency @join__type(graph: AGENCY, key: "id") @join__type(graph: PRODUCTS) {
50+
id: ID!
51+
companyName: String @join__field(graph: AGENCY)
52+
email: Email @join__field(graph: AGENCY)
53+
}
54+
55+
type Book implements Product & Similar
56+
@join__implements(graph: INVENTORY, interface: "Product")
57+
@join__implements(graph: PRODUCTS, interface: "Product")
58+
@join__implements(graph: PRODUCTS, interface: "Similar")
59+
@join__implements(graph: REVIEWS, interface: "Product")
60+
@join__implements(graph: REVIEWS, interface: "Similar")
61+
@join__type(graph: BOOKS, key: "id")
62+
@join__type(graph: INVENTORY, key: "id")
63+
@join__type(graph: PRODUCTS, key: "id")
64+
@join__type(graph: REVIEWS, key: "id") {
65+
id: ID!
66+
title: String @join__field(graph: BOOKS)
67+
dimensions: ProductDimension
68+
@join__field(graph: INVENTORY, external: true)
69+
@join__field(graph: PRODUCTS)
70+
delivery(zip: String): DeliveryEstimates
71+
@join__field(graph: INVENTORY, requires: "dimensions { size weight }")
72+
sku: String @join__field(graph: PRODUCTS)
73+
createdBy: User @join__field(graph: PRODUCTS)
74+
similar: [Book]
75+
@join__field(graph: PRODUCTS)
76+
@join__field(graph: REVIEWS, external: true)
77+
hidden: Boolean @join__field(graph: PRODUCTS)
78+
publisherType: PublisherType @join__field(graph: PRODUCTS)
79+
reviewsCount: Int! @join__field(graph: REVIEWS)
80+
reviewsScore: Float! @join__field(graph: REVIEWS)
81+
reviews: [Review!]! @join__field(graph: REVIEWS)
82+
reviewsOfSimilar: [Review!]!
83+
@join__field(graph: REVIEWS, requires: "similar { id }")
84+
}
85+
86+
type DeliveryEstimates @join__type(graph: INVENTORY) {
87+
estimatedDelivery: String
88+
fastestDelivery: String
89+
}
90+
91+
type Email @join__type(graph: AGENCY) {
92+
address: String
93+
}
94+
95+
type Group @join__type(graph: AGENCY, key: "id") {
96+
id: ID!
97+
name: String
98+
email: String
99+
}
100+
101+
scalar join__FieldSet
102+
103+
enum join__Graph {
104+
AGENCY
105+
@join__graph(
106+
name: "agency"
107+
url: "http://localhost:4200/abstract-types/agency"
108+
)
109+
BOOKS
110+
@join__graph(
111+
name: "books"
112+
url: "http://localhost:4200/abstract-types/books"
113+
)
114+
INVENTORY
115+
@join__graph(
116+
name: "inventory"
117+
url: "http://localhost:4200/abstract-types/inventory"
118+
)
119+
MAGAZINES
120+
@join__graph(
121+
name: "magazines"
122+
url: "http://localhost:4200/abstract-types/magazines"
123+
)
124+
PRODUCTS
125+
@join__graph(
126+
name: "products"
127+
url: "http://localhost:4200/abstract-types/products"
128+
)
129+
REVIEWS
130+
@join__graph(
131+
name: "reviews"
132+
url: "http://localhost:4200/abstract-types/reviews"
133+
)
134+
USERS
135+
@join__graph(
136+
name: "users"
137+
url: "http://localhost:4200/abstract-types/users"
138+
)
139+
}
140+
141+
scalar link__Import
142+
143+
enum link__Purpose {
144+
"""
145+
`SECURITY` features provide metadata necessary to securely resolve fields.
146+
"""
147+
SECURITY
148+
149+
"""
150+
`EXECUTION` features provide metadata necessary for operation execution.
151+
"""
152+
EXECUTION
153+
}
154+
155+
type Magazine implements Product & Similar
156+
@join__implements(graph: INVENTORY, interface: "Product")
157+
@join__implements(graph: PRODUCTS, interface: "Product")
158+
@join__implements(graph: PRODUCTS, interface: "Similar")
159+
@join__implements(graph: REVIEWS, interface: "Product")
160+
@join__implements(graph: REVIEWS, interface: "Similar")
161+
@join__type(graph: INVENTORY, key: "id")
162+
@join__type(graph: MAGAZINES, key: "id")
163+
@join__type(graph: PRODUCTS, key: "id")
164+
@join__type(graph: REVIEWS, key: "id") {
165+
id: ID!
166+
dimensions: ProductDimension
167+
@join__field(graph: INVENTORY, external: true)
168+
@join__field(graph: PRODUCTS)
169+
delivery(zip: String): DeliveryEstimates
170+
@join__field(graph: INVENTORY, requires: "dimensions { size weight }")
171+
title: String @join__field(graph: MAGAZINES)
172+
sku: String @join__field(graph: PRODUCTS)
173+
createdBy: User @join__field(graph: PRODUCTS)
174+
similar: [Magazine]
175+
@join__field(graph: PRODUCTS)
176+
@join__field(graph: REVIEWS, external: true)
177+
hidden: Boolean @join__field(graph: PRODUCTS)
178+
publisherType: PublisherType @join__field(graph: PRODUCTS)
179+
reviewsCount: Int! @join__field(graph: REVIEWS)
180+
reviewsScore: Float! @join__field(graph: REVIEWS)
181+
reviews: [Review!]! @join__field(graph: REVIEWS)
182+
reviewsOfSimilar: [Review!]!
183+
@join__field(graph: REVIEWS, requires: "similar { id }")
184+
}
185+
186+
interface Product
187+
@join__type(graph: INVENTORY)
188+
@join__type(graph: PRODUCTS)
189+
@join__type(graph: REVIEWS) {
190+
id: ID!
191+
dimensions: ProductDimension
192+
@join__field(graph: INVENTORY)
193+
@join__field(graph: PRODUCTS)
194+
delivery(zip: String): DeliveryEstimates @join__field(graph: INVENTORY)
195+
sku: String @join__field(graph: PRODUCTS)
196+
createdBy: User @join__field(graph: PRODUCTS)
197+
hidden: Boolean @inaccessible @join__field(graph: PRODUCTS)
198+
reviewsCount: Int! @join__field(graph: REVIEWS)
199+
reviewsScore: Float! @join__field(graph: REVIEWS)
200+
reviews: [Review!]! @join__field(graph: REVIEWS)
201+
}
202+
203+
type ProductDimension
204+
@join__type(graph: INVENTORY)
205+
@join__type(graph: PRODUCTS) {
206+
size: String
207+
weight: Float
208+
}
209+
210+
union PublisherType
211+
@join__type(graph: AGENCY)
212+
@join__type(graph: PRODUCTS)
213+
@join__unionMember(graph: AGENCY, member: "Agency")
214+
@join__unionMember(graph: PRODUCTS, member: "Agency")
215+
@join__unionMember(graph: AGENCY, member: "Group")
216+
@join__unionMember(graph: PRODUCTS, member: "Self") =
217+
| Agency
218+
| Group
219+
| Self
220+
221+
type Query
222+
@join__type(graph: AGENCY)
223+
@join__type(graph: BOOKS)
224+
@join__type(graph: INVENTORY)
225+
@join__type(graph: MAGAZINES)
226+
@join__type(graph: PRODUCTS)
227+
@join__type(graph: REVIEWS)
228+
@join__type(graph: USERS) {
229+
books: [Book] @join__field(graph: BOOKS)
230+
magazines: [Magazine] @join__field(graph: MAGAZINES)
231+
products: [Product] @join__field(graph: PRODUCTS)
232+
similar(id: ID!): [Product] @join__field(graph: PRODUCTS)
233+
review(id: Int!): Review @join__field(graph: REVIEWS)
234+
}
235+
236+
type Review @join__type(graph: REVIEWS) {
237+
id: Int!
238+
body: String!
239+
product: Product
240+
}
241+
242+
type Self @join__type(graph: PRODUCTS) {
243+
email: String
244+
}
245+
246+
interface Similar @join__type(graph: PRODUCTS) @join__type(graph: REVIEWS) {
247+
similar: [Product]
248+
}
249+
250+
type User
251+
@join__type(graph: PRODUCTS, key: "email")
252+
@join__type(graph: USERS, key: "email") {
253+
email: ID!
254+
totalProductsCreated: Int
255+
name: String @join__field(graph: USERS)
256+
}

lib/query-planner/src/planner/plan_nodes.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,7 @@ impl PlanNode {
378378
} else {
379379
PlanNode::Flatten(FlattenNode {
380380
// it's cheaper to clone response_path (Arc etc), rather then cloning the step
381-
path: if step.is_fetching_multiple_types() {
382-
step.response_path.without_type_castings().into()
383-
} else {
384-
step.response_path.clone().into()
385-
},
381+
path: step.response_path.without_type_castings().into(),
386382
node: Box::new(PlanNode::Fetch(FetchNode::from_fetch_step(
387383
step, supergraph,
388384
))),

lib/query-planner/src/tests/alias.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn circular_reference_interface() -> Result<(), Box<dyn Error>> {
4545
document,
4646
)?;
4747

48-
insta::assert_snapshot!(format!("{}", query_plan), @r#"
48+
insta::assert_snapshot!(format!("{}", query_plan), @r###"
4949
QueryPlan {
5050
Sequence {
5151
Fetch(service: "a") {
@@ -76,7 +76,7 @@ fn circular_reference_interface() -> Result<(), Box<dyn Error>> {
7676
id
7777
}
7878
},
79-
Flatten(path: "product|[Book]") {
79+
Flatten(path: "product") {
8080
Fetch(service: "b") {
8181
{
8282
... on Book {
@@ -93,7 +93,7 @@ fn circular_reference_interface() -> Result<(), Box<dyn Error>> {
9393
},
9494
},
9595
},
96-
"#);
96+
"###);
9797

9898
Ok(())
9999
}

0 commit comments

Comments
 (0)