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