Skip to content

Commit 4d9a2dd

Browse files
committed
validation code moved over and updated to meet new naming conventions. test coverage not passing.
1 parent 699ec58 commit 4d9a2dd

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/validation/__tests__/harness.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expectJSON } from '../../__testUtils__/expectJSON';
22

33
import type { Maybe } from '../../jsutils/Maybe';
44

5+
import type { ParseOptions } from '../../language/parser';
56
import { parse } from '../../language/parser';
67

78
import 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

128130
export 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

135143
export function expectSDLValidationErrors(

src/validation/rules/OverlappingFieldsCanBeMergedRule.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
isObjectType,
2929
} from '../../type/definition';
3030

31+
import { applyRequiredStatus } from '../../utilities/applyRequiredStatus';
3132
import { sortValueNode } from '../../utilities/sortValueNode';
3233
import { 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

0 commit comments

Comments
 (0)