@@ -38,6 +38,7 @@ describe('passes along errors for missing fields on list', () => {
38
38
const originalResult = await graphql ( schema , query ) ;
39
39
const stitchedResult = await graphql ( stitchedSchema , query ) ;
40
40
expect ( stitchedResult ) . toEqual ( originalResult ) ;
41
+ expect ( stitchedResult . errors [ 0 ] . path ) . toEqual ( originalResult . errors [ 0 ] . path ) ;
41
42
} ) ;
42
43
43
44
test ( 'even if nullable' , async ( ) => {
@@ -72,6 +73,7 @@ describe('passes along errors for missing fields on list', () => {
72
73
const originalResult = await graphql ( schema , query ) ;
73
74
const stitchedResult = await graphql ( stitchedSchema , query ) ;
74
75
expect ( stitchedResult ) . toEqual ( originalResult ) ;
76
+ expect ( stitchedResult . errors [ 0 ] . path ) . toEqual ( originalResult . errors [ 0 ] . path ) ;
75
77
} ) ;
76
78
} ) ;
77
79
@@ -108,6 +110,7 @@ describe('passes along errors when list field errors', () => {
108
110
const originalResult = await graphql ( schema , query ) ;
109
111
const stitchedResult = await graphql ( stitchedSchema , query ) ;
110
112
expect ( stitchedResult ) . toEqual ( originalResult ) ;
113
+ expect ( stitchedResult . errors [ 0 ] . path ) . toEqual ( originalResult . errors [ 0 ] . path ) ;
111
114
} ) ;
112
115
113
116
test ( 'even if nullable' , async ( ) => {
@@ -142,6 +145,38 @@ describe('passes along errors when list field errors', () => {
142
145
const originalResult = await graphql ( schema , query ) ;
143
146
const stitchedResult = await graphql ( stitchedSchema , query ) ;
144
147
expect ( stitchedResult ) . toEqual ( originalResult ) ;
148
+ expect ( stitchedResult . errors [ 0 ] . path ) . toEqual ( originalResult . errors [ 0 ] . path ) ;
149
+ } ) ;
150
+
151
+ describe ( 'passes along correct error when there are two non-null fields' , ( ) => {
152
+ test ( 'should work' , async ( ) => {
153
+ const schema = makeExecutableSchema ( {
154
+ typeDefs : `
155
+ type Query {
156
+ getBoth: Both
157
+ }
158
+ type Both {
159
+ mandatoryField1: String!
160
+ mandatoryField2: String!
161
+ }
162
+ ` ,
163
+ resolvers : {
164
+ Query : {
165
+ getBoth : ( ) => ( { mandatoryField1 : 'test' } ) ,
166
+ } ,
167
+ } ,
168
+ } ) ;
169
+
170
+ const stitchedSchema = stitchSchemas ( {
171
+ subschemas : [ schema ] ,
172
+ } ) ;
173
+
174
+ const query = '{ getBoth { mandatoryField1 mandatoryField2 } }' ;
175
+ const originalResult = await graphql ( schema , query ) ;
176
+ const stitchedResult = await graphql ( stitchedSchema , query ) ;
177
+ expect ( stitchedResult ) . toEqual ( originalResult ) ;
178
+ expect ( stitchedResult . errors [ 0 ] . path ) . toEqual ( originalResult . errors [ 0 ] . path ) ;
179
+ } ) ;
145
180
} ) ;
146
181
} ) ;
147
182
0 commit comments