Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/type/__tests__/validation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1703,20 +1703,25 @@ describe('Objects must adhere to Interface they implement', () => {
}

interface AnotherInterface {
field(input: String): String
field(baseArg: String): String
}

type AnotherObject implements AnotherInterface {
field(input: String, anotherInput: String!): String
field(
baseArg: String,
requiredArg: String!
optionalArg1: String,
optionalArg2: String = "",
): String
}
`);
expect(validateSchema(schema)).to.deep.equal([
{
message:
'Object field argument AnotherObject.field(anotherInput:) is of ' +
'required type String! but is not also provided by the Interface ' +
'field AnotherInterface.field.',
locations: [{ line: 11, column: 44 }, { line: 7, column: 9 }],
'Object field AnotherObject.field includes required argument ' +
'requiredArg that is missing from the Interface field ' +
'AnotherInterface.field.',
locations: [{ line: 13, column: 11 }, { line: 7, column: 9 }],
},
]);
});
Expand Down
12 changes: 6 additions & 6 deletions src/type/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
isUnionType,
isEnumType,
isInputObjectType,
isNonNullType,
isNamedType,
isInputType,
isOutputType,
isRequiredArgument,
} from './definition';
import type {
GraphQLObjectType,
Expand Down Expand Up @@ -438,13 +438,13 @@ function validateObjectImplementsInterface(
for (const objectArg of objectField.args) {
const argName = objectArg.name;
const ifaceArg = find(ifaceField.args, arg => arg.name === argName);
if (!ifaceArg && isNonNullType(objectArg.type)) {
if (!ifaceArg && isRequiredArgument(objectArg)) {
context.reportError(
`Object field argument ${object.name}.${fieldName}(${argName}:) ` +
`is of required type ${inspect(objectArg.type)} but is not also ` +
`provided by the Interface field ${iface.name}.${fieldName}.`,
`Object field ${object.name}.${fieldName} includes required ` +
`argument ${argName} that is missing from the Interface field ` +
`${iface.name}.${fieldName}.`,
[
getFieldArgTypeNode(object, fieldName, argName),
getFieldArgNode(object, fieldName, argName),
getFieldNode(iface, fieldName),
],
);
Expand Down