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';
22
33import type { Maybe } from '../../jsutils/Maybe' ;
44
5+ import type { ParseOptions } from '../../language/parser' ;
56import { parse } from '../../language/parser' ;
67
78import type { GraphQLSchema } from '../../type/schema' ;
@@ -119,17 +120,24 @@ export function expectValidationErrorsWithSchema(
119120 schema : GraphQLSchema ,
120121 rule : ValidationRule ,
121122 queryStr : string ,
123+ parseOptions ?: ParseOptions ,
122124) : any {
123- const doc = parse ( queryStr ) ;
125+ const doc = parse ( queryStr , parseOptions ) ;
124126 const errors = validate ( schema , doc , [ rule ] ) ;
125127 return expectJSON ( errors ) ;
126128}
127129
128130export function expectValidationErrors (
129131 rule : ValidationRule ,
130132 queryStr : string ,
133+ parseOptions ?: ParseOptions ,
131134) : any {
132- return expectValidationErrorsWithSchema ( testSchema , rule , queryStr ) ;
135+ return expectValidationErrorsWithSchema (
136+ testSchema ,
137+ rule ,
138+ queryStr ,
139+ parseOptions ,
140+ ) ;
133141}
134142
135143export function expectSDLValidationErrors (
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import {
2828 isObjectType ,
2929} from '../../type/definition' ;
3030
31+ import { applyRequiredStatus } from '../../utilities/applyRequiredStatus' ;
3132import { sortValueNode } from '../../utilities/sortValueNode' ;
3233import { typeFromAST } from '../../utilities/typeFromAST' ;
3334
@@ -605,17 +606,22 @@ function findConflict(
605606 const type1 = def1 ?. type ;
606607 const type2 = def2 ?. type ;
607608
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+ }
619625 }
620626
621627 // Collect and compare sub-fields. Use the same "visited fragment names" list
You can’t perform that action at this time.
0 commit comments