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
5 changes: 0 additions & 5 deletions .changeset/slow-cups-exist.md

This file was deleted.

34 changes: 1 addition & 33 deletions composition-js/src/__tests__/compose.external.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('tests related to @external', () => {
typeDefs: gql`
type T @key(fields: "id") {
id: ID!
f(x: Int!): String @shareable
f(x: Int): String @shareable
}
`,
};
Expand All @@ -73,38 +73,6 @@ describe('tests related to @external', () => {
['EXTERNAL_ARGUMENT_MISSING', 'Field "T.f" is missing argument "T.f(x:)" in some subgraphs where it is marked @external: argument "T.f(x:)" is declared in subgraph "subgraphB" but not in subgraph "subgraphA" (where "T.f" is @external).'],
]);
});

it('succeeds on @external definition where difference between definitions is an optional argument', () => {
const subgraphA = {
name: 'subgraphA',
typeDefs: gql`
type Query {
locations: [Location]
}

type Location @key(fields: "id") {
id: ID!
name: String!
photo(smallVersion: Boolean): String! # New optional arg shouldn't break existing clients
}
`,
};

const subgraphB = {
name: 'subgraphB',
typeDefs: gql`
type Location @key(fields: "id") {
id: ID!
photo: String! @external
banner: String @requires(fields: "photo")
}
`,
};

const result = composeAsFed2Subgraphs([subgraphA, subgraphB]);
assertCompositionSuccess(result);
});


it('errors on incompatible argument types in @external declaration', () => {
const subgraphA = {
Expand Down
4 changes: 1 addition & 3 deletions composition-js/src/merging/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1864,9 +1864,7 @@ class Merger {
const name = destArg.name;
const arg = source.argument(name);
if (!arg) {
if (!destArg.type || destArg.type.kind === 'NonNullType') {
invalidArgsPresence.add(name);
}
invalidArgsPresence.add(name);
continue;
}
if (!sameType(destArg.type!, arg.type!) && !this.isStrictSubtype(arg.type!, destArg.type!)) {
Expand Down