Skip to content

Commit b48d864

Browse files
committed
add test cases to show min join version is used for various fed versions
1 parent cae9be3 commit b48d864

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

composition-js/src/__tests__/compose.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,6 +4655,39 @@ describe('composition', () => {
46554655
const authenticatedDirectiveExists = schema.directives().find(d => d.name === 'authenticated');
46564656
expect(authenticatedDirectiveExists).toBeUndefined();
46574657
});
4658+
4659+
describe('uses minimum required spec versions', () => {
4660+
function subgraphWithFederationSpecVersion(version: string) {
4661+
const schemaString = `
4662+
extend schema @link(url: "https://specs.apollo.dev/federation/v${version}", import: ["@key"])
4663+
4664+
type Query {
4665+
a: A
4666+
}
4667+
4668+
type A @key(fields: "id") {
4669+
id: ID!
4670+
}
4671+
`;
4672+
return {
4673+
typeDefs: gql`${schemaString}`,
4674+
name: 'subgraphA',
4675+
};
4676+
}
4677+
4678+
it.each([
4679+
{ subgraphFedVersion: "2.4", expectedJoinVersion: "0.3"},
4680+
{ subgraphFedVersion: "2.5", expectedJoinVersion: "0.3"},
4681+
{ subgraphFedVersion: "2.6", expectedJoinVersion: "0.3"},
4682+
{ subgraphFedVersion: "2.7", expectedJoinVersion: "0.4"},
4683+
{ subgraphFedVersion: "2.8", expectedJoinVersion: "0.5" },
4684+
])("federation -> join versions", ({ subgraphFedVersion, expectedJoinVersion }) => {
4685+
const subgraph = subgraphWithFederationSpecVersion(subgraphFedVersion);
4686+
const result = composeServices([subgraph]);
4687+
assertCompositionSuccess(result);
4688+
expect(result.supergraphSdl).toContain(`join/v${expectedJoinVersion}`);
4689+
});
4690+
});
46584691
});
46594692

46604693
describe('@source* directives', () => {

0 commit comments

Comments
 (0)