File tree Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { expectJSON } from '../../__testUtils__/expectJSON';
2
2
3
3
import type { Maybe } from '../../jsutils/Maybe' ;
4
4
5
+ import type { ParseOptions } from '../../language/parser' ;
5
6
import { parse } from '../../language/parser' ;
6
7
7
8
import type { GraphQLSchema } from '../../type/schema' ;
@@ -119,17 +120,24 @@ export function expectValidationErrorsWithSchema(
119
120
schema : GraphQLSchema ,
120
121
rule : ValidationRule ,
121
122
queryStr : string ,
123
+ parseOptions ?: ParseOptions ,
122
124
) : any {
123
- const doc = parse ( queryStr ) ;
125
+ const doc = parse ( queryStr , parseOptions ) ;
124
126
const errors = validate ( schema , doc , [ rule ] ) ;
125
127
return expectJSON ( errors ) ;
126
128
}
127
129
128
130
export function expectValidationErrors (
129
131
rule : ValidationRule ,
130
132
queryStr : string ,
133
+ parseOptions ?: ParseOptions ,
131
134
) : any {
132
- return expectValidationErrorsWithSchema ( testSchema , rule , queryStr ) ;
135
+ return expectValidationErrorsWithSchema (
136
+ testSchema ,
137
+ rule ,
138
+ queryStr ,
139
+ parseOptions ,
140
+ ) ;
133
141
}
134
142
135
143
export function expectSDLValidationErrors (
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import {
28
28
isObjectType ,
29
29
} from '../../type/definition' ;
30
30
31
+ import { applyRequiredStatus } from '../../utilities/applyRequiredStatus' ;
31
32
import { sortValueNode } from '../../utilities/sortValueNode' ;
32
33
import { typeFromAST } from '../../utilities/typeFromAST' ;
33
34
@@ -605,17 +606,22 @@ function findConflict(
605
606
const type1 = def1 ?. type ;
606
607
const type2 = def2 ?. type ;
607
608
608
- if ( type1 && type2 && doTypesConflict ( type1 , type2 ) ) {
609
- return [
610
- [
611
- responseName ,
612
- `they return conflicting types "${ inspect ( type1 ) } " and "${ inspect (
613
- type2 ,
614
- ) } "`,
615
- ] ,
616
- [ node1 ] ,
617
- [ node2 ] ,
618
- ] ;
609
+ if ( type1 && type2 ) {
610
+ const modifiedType1 = applyRequiredStatus ( type1 , node1 . nullabilityAssertion ) ;
611
+ const modifiedType2 = applyRequiredStatus ( type2 , node2 . nullabilityAssertion ) ;
612
+
613
+ if ( doTypesConflict ( modifiedType1 , modifiedType2 ) ) {
614
+ return [
615
+ [
616
+ responseName ,
617
+ `they return conflicting types "${ inspect (
618
+ modifiedType1 ,
619
+ ) } " and "${ inspect ( modifiedType2 ) } "`,
620
+ ] ,
621
+ [ node1 ] ,
622
+ [ node2 ] ,
623
+ ] ;
624
+ }
619
625
}
620
626
621
627
// Collect and compare sub-fields. Use the same "visited fragment names" list
You can’t perform that action at this time.
0 commit comments