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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ private static void Handle(

foreach (var interfaceField in accessibleInterfaceFields)
{
var field = type.Fields[interfaceField.Name];
// An implementing type can be missing fields that were contributed to a merged
// interface by another source schema. That missing-field case is validated
// separately (e.g. by InterfaceFieldNoImplementationRule for object types), so we
// skip it here to avoid throwing when looking up the field on the implementing type.
if (!type.Fields.TryGetField(interfaceField.Name, out var field))
{
continue;
}

if (field.HasFusionInaccessibleDirective()
|| type.HasFusionInaccessibleDirective())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,34 @@ interface User implements Node {
"""
]);
}

// When two source schemas declare the same-named interface with different fields, the merged
// interface holds the union of those fields, so an implementing type does not necessarily
// provide every field of the interface. This rule must not assume the field exists on the
// implementing type; the unimplemented field is reported by InterfaceFieldNoImplementationRule.
[Fact]
public void Validate_MergedInterfaceFieldNotOnAllImplementers_Succeeds()
{
AssertValid(
[
"""
interface Error {
code: String!
}

type ErrorWithCode implements Error {
code: String!
}
""",
"""
interface Error {
message: String!
}

type ErrorWithMessage implements Error {
message: String!
}
"""
]);
}
}
Loading