File tree Expand file tree Collapse file tree 8 files changed +661
-4
lines changed
Expand file tree Collapse file tree 8 files changed +661
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @graphql-tools/delegate ' : patch
3+ ' @graphql-tools/stitch ' : patch
4+ ' @graphql-tools/utils ' : patch
5+ ---
6+
7+ Handle ` @defer `
Original file line number Diff line number Diff line change 1+ ---
2+ ' @graphql-tools/federation ' : patch
3+ ---
4+
5+ Exclude ` @defer ` in the subgraph requests
Original file line number Diff line number Diff line change @@ -222,6 +222,8 @@ function visitSelectionSet(
222222 if ( possibleTypes . length === 0 ) {
223223 newSelections . add ( selection ) ;
224224 }
225+ } else {
226+ newSelections . add ( selection ) ;
225227 }
226228 } else if ( selection . kind === Kind . FRAGMENT_SPREAD ) {
227229 const fragmentName = selection . name . value ;
Original file line number Diff line number Diff line change @@ -872,6 +872,12 @@ export function getStitchingOptionsFromSupergraphSdl(
872872 document : visit (
873873 request . document ,
874874 visitWithTypeInfo ( typeInfo , {
875+ [ Kind . DIRECTIVE ] ( node ) {
876+ if ( node . name . value === 'defer' ) {
877+ // @defer is not available for the communication between the gw and subgraph
878+ return null ;
879+ }
880+ } ,
875881 // To avoid resolving unresolvable interface fields
876882 [ Kind . FIELD ] ( node ) {
877883 if ( node . name . value !== '__typename' ) {
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` Defer defers the nested fields: defer-nested-fields 1` ] = `
4+ [
5+ {
6+ " data" : {
7+ " users" : [
8+ {
9+ " id" : " 1" ,
10+ " name" : " Ada Lovelace" ,
11+ },
12+ {
13+ " id" : " 2" ,
14+ " name" : " Alan Turing" ,
15+ },
16+ ],
17+ },
18+ " hasNext" : true ,
19+ } ,
20+ {
21+ " hasNext" : true ,
22+ " incremental" : [
23+ {
24+ " data" : {
25+ " posts" : [
26+ {
27+ " author" : {
28+ " id" : " 1" ,
29+ " posts" : [
30+ {
31+ " id" : " 1" ,
32+ " title" : " Hello, World!" ,
33+ },
34+ ],
35+ },
36+ " id" : " 1" ,
37+ " title" : " Hello, World!" ,
38+ },
39+ {
40+ " author" : {
41+ " id" : " 2" ,
42+ " posts" : [
43+ {
44+ " id" : " 2" ,
45+ " title" : " My Story" ,
46+ },
47+ ],
48+ },
49+ " id" : " 2" ,
50+ " title" : " My Story" ,
51+ },
52+ ],
53+ },
54+ " path" : [],
55+ },
56+ {
57+ " data" : {
58+ " name" : " Ada Lovelace" ,
59+ },
60+ " path" : [
61+ " posts" ,
62+ 0 ,
63+ " author" ,
64+ ],
65+ },
66+ {
67+ " data" : {
68+ " name" : " Alan Turing" ,
69+ },
70+ " path" : [
71+ " posts" ,
72+ 1 ,
73+ " author" ,
74+ ],
75+ },
76+ ],
77+ } ,
78+ {
79+ " hasNext" : true ,
80+ " incremental" : [
81+ {
82+ " data" : {
83+ " posts" : [
84+ {
85+ " author" : {
86+ " id" : " 1" ,
87+ },
88+ " id" : " 1" ,
89+ },
90+ ],
91+ },
92+ " path" : [
93+ " users" ,
94+ 0 ,
95+ ],
96+ },
97+ {
98+ " data" : {
99+ " posts" : [
100+ {
101+ " author" : {
102+ " id" : " 2" ,
103+ },
104+ " id" : " 2" ,
105+ },
106+ ],
107+ },
108+ " path" : [
109+ " users" ,
110+ 1 ,
111+ ],
112+ },
113+ ],
114+ } ,
115+ {
116+ " hasNext" : false ,
117+ " incremental" : [
118+ {
119+ " data" : {
120+ " title" : " Hello, World!" ,
121+ },
122+ " path" : [
123+ " users" ,
124+ 0 ,
125+ " posts" ,
126+ 0 ,
127+ ],
128+ },
129+ {
130+ " data" : {
131+ " title" : " My Story" ,
132+ },
133+ " path" : [
134+ " users" ,
135+ 1 ,
136+ " posts" ,
137+ 0 ,
138+ ],
139+ },
140+ {
141+ " data" : {
142+ " name" : " Ada Lovelace" ,
143+ },
144+ " path" : [
145+ " users" ,
146+ 0 ,
147+ " posts" ,
148+ 0 ,
149+ " author" ,
150+ ],
151+ },
152+ {
153+ " data" : {
154+ " name" : " Alan Turing" ,
155+ },
156+ " path" : [
157+ " users" ,
158+ 1 ,
159+ " posts" ,
160+ 0 ,
161+ " author" ,
162+ ],
163+ },
164+ ],
165+ } ,
166+ ]
167+ ` ;
168+
169+ exports [` Defer defers the root fields: defer-root-fields 1` ] = `
170+ [
171+ {
172+ " data" : {},
173+ " hasNext" : true ,
174+ } ,
175+ {
176+ " hasNext" : true ,
177+ " incremental" : [
178+ {
179+ " data" : {
180+ " users" : [
181+ {
182+ " id" : " 1" ,
183+ " name" : " Ada Lovelace" ,
184+ " posts" : [
185+ {
186+ " author" : {
187+ " id" : " 1" ,
188+ " name" : " Ada Lovelace" ,
189+ },
190+ " id" : " 1" ,
191+ " title" : " Hello, World!" ,
192+ },
193+ ],
194+ },
195+ {
196+ " id" : " 2" ,
197+ " name" : " Alan Turing" ,
198+ " posts" : [
199+ {
200+ " author" : {
201+ " id" : " 2" ,
202+ " name" : " Alan Turing" ,
203+ },
204+ " id" : " 2" ,
205+ " title" : " My Story" ,
206+ },
207+ ],
208+ },
209+ ],
210+ },
211+ " path" : [],
212+ },
213+ ],
214+ } ,
215+ {
216+ " hasNext" : false ,
217+ " incremental" : [
218+ {
219+ " data" : {
220+ " posts" : [
221+ {
222+ " author" : {
223+ " id" : " 1" ,
224+ " name" : " Ada Lovelace" ,
225+ " posts" : [
226+ {
227+ " id" : " 1" ,
228+ " title" : " Hello, World!" ,
229+ },
230+ ],
231+ },
232+ " id" : " 1" ,
233+ " title" : " Hello, World!" ,
234+ },
235+ {
236+ " author" : {
237+ " id" : " 2" ,
238+ " name" : " Alan Turing" ,
239+ " posts" : [
240+ {
241+ " id" : " 2" ,
242+ " title" : " My Story" ,
243+ },
244+ ],
245+ },
246+ " id" : " 2" ,
247+ " title" : " My Story" ,
248+ },
249+ ],
250+ },
251+ " path" : [],
252+ },
253+ ],
254+ } ,
255+ ]
256+ ` ;
You can’t perform that action at this time.
0 commit comments