Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
27 changes: 27 additions & 0 deletions src/type/__tests__/validation-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3353,6 +3353,33 @@ describe('Interfaces must adhere to Interface they implement', () => {
},
]);
});

it('rejects deprecated implementation field when interface field is not deprecated', () => {
const schema = buildSchema(`
interface Node {
id: ID!
}

type Foo implements Node {
id: ID! @deprecated
}

type Query {
foo: Foo
}
`);

expectJSON(validateSchema(schema)).toDeepEqual([
{
message:
'Interface field Node.id is not deprecated, so implementation field Foo.id must not be deprecated.',
locations: [
{ line: 7, column: 17 },
{ line: 7, column: 13 },
],
},
]);
});
});

describe('assertValidSchema', () => {
Expand Down
15 changes: 15 additions & 0 deletions src/type/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,21 @@
}
}
}

// Asserts that field is not deprecated unless interface field is
if (
typeField.deprecationReason != null &&
ifaceField.deprecationReason == null
) {
context.reportError(
`Interface field ${iface.name}.${fieldName} is not deprecated, so ` +

Check failure on line 583 in src/type/validate.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

'fieldName' is not defined

Check failure on line 583 in src/type/validate.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

'fieldName' is not defined
`implementation field ${type.name}.${fieldName} must not be deprecated.`,

Check failure on line 584 in src/type/validate.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

'fieldName' is not defined

Check failure on line 584 in src/type/validate.ts

View workflow job for this annotation

GitHub Actions / ci / Lint source files

'fieldName' is not defined
[
getDeprecatedDirectiveNode(typeField.astNode),
typeField.astNode?.type,
],
);
}
}
}

Expand Down
Loading