Skip to content

Commit eae6f5a

Browse files
committed
Remove oneOf validation from values of correct type
1 parent 9032db1 commit eae6f5a

File tree

2 files changed

+0
-35
lines changed

2 files changed

+0
-35
lines changed

src/validation/__tests__/ValuesOfCorrectTypeRule-test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,22 +1094,6 @@ describe('Validate: Values of correct type', () => {
10941094
]);
10951095
});
10961096

1097-
it('Exactly one nullable variable', () => {
1098-
expectErrors(`
1099-
query ($string: String) {
1100-
complicatedArgs {
1101-
oneOfArgField(oneOfArg: { stringField: $string })
1102-
}
1103-
}
1104-
`).toDeepEqual([
1105-
{
1106-
message:
1107-
'Variable "string" must be non-nullable to be used for OneOf Input Object "OneOfInput".',
1108-
locations: [{ line: 4, column: 37 }],
1109-
},
1110-
]);
1111-
});
1112-
11131097
it('More than one field', () => {
11141098
expectErrors(`
11151099
{

src/validation/rules/ValuesOfCorrectTypeRule.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export function ValuesOfCorrectTypeRule(
8787
node,
8888
type,
8989
fieldNodeMap,
90-
variableDefinitions,
9190
);
9291
}
9392
},
@@ -185,7 +184,6 @@ function validateOneOfInputObject(
185184
node: ObjectValueNode,
186185
type: GraphQLInputObjectType,
187186
fieldNodeMap: ObjMap<ObjectFieldNode>,
188-
variableDefinitions: { [key: string]: VariableDefinitionNode },
189187
): void {
190188
const keys = Object.keys(fieldNodeMap);
191189
const isNotExactlyOneField = keys.length !== 1;
@@ -202,29 +200,12 @@ function validateOneOfInputObject(
202200

203201
const value = fieldNodeMap[keys[0]]?.value;
204202
const isNullLiteral = !value || value.kind === Kind.NULL;
205-
const isVariable = value?.kind === Kind.VARIABLE;
206203

207204
if (isNullLiteral) {
208205
context.reportError(
209206
new GraphQLError(`Field "${type.name}.${keys[0]}" must be non-null.`, {
210207
nodes: [node],
211208
}),
212209
);
213-
return;
214-
}
215-
216-
if (isVariable) {
217-
const variableName = value.name.value;
218-
const definition = variableDefinitions[variableName];
219-
const isNullableVariable = definition.type.kind !== Kind.NON_NULL_TYPE;
220-
221-
if (isNullableVariable) {
222-
context.reportError(
223-
new GraphQLError(
224-
`Variable "${variableName}" must be non-nullable to be used for OneOf Input Object "${type.name}".`,
225-
{ nodes: [node] },
226-
),
227-
);
228-
}
229210
}
230211
}

0 commit comments

Comments
 (0)