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';
22
33import type { Maybe } from '../../jsutils/Maybe.js' ;
44
5- import { parse } from '../../language/parser.js' ;
5+ import type { ParseOptions } from '../../language/parser' ;
6+ import { parse } from '../../language/parser' ;
67
78import type { GraphQLSchema } from '../../type/schema.js' ;
89
@@ -122,17 +123,24 @@ export function expectValidationErrorsWithSchema(
122123 schema : GraphQLSchema ,
123124 rule : ValidationRule ,
124125 queryStr : string ,
126+ parseOptions ?: ParseOptions ,
125127) : any {
126- const doc = parse ( queryStr ) ;
128+ const doc = parse ( queryStr , parseOptions ) ;
127129 const errors = validate ( schema , doc , [ rule ] ) ;
128130 return expectJSON ( errors ) ;
129131}
130132
131133export function expectValidationErrors (
132134 rule : ValidationRule ,
133135 queryStr : string ,
136+ parseOptions ?: ParseOptions ,
134137) : any {
135- return expectValidationErrorsWithSchema ( testSchema , rule , queryStr ) ;
138+ return expectValidationErrorsWithSchema (
139+ testSchema ,
140+ rule ,
141+ queryStr ,
142+ parseOptions ,
143+ ) ;
136144}
137145
138146export function expectSDLValidationErrors (
Original file line number Diff line number Diff line change @@ -29,8 +29,9 @@ import {
2929 isObjectType ,
3030} from '../../type/definition.js' ;
3131
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' ;
3435
3536import type { ValidationContext } from '../ValidationContext.js' ;
3637
@@ -617,17 +618,22 @@ function findConflict(
617618 const type1 = def1 ?. type ;
618619 const type2 = def2 ?. type ;
619620
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+ }
631637 }
632638
633639 // Collect and compare sub-fields. Use the same "visited fragment names" list
You can’t perform that action at this time.
0 commit comments