Skip to content

Commit

Permalink
Merge pull request #3151 from apollographql/lb/merge-main
Browse files Browse the repository at this point in the history
merge main into next
  • Loading branch information
lennyburdette authored Sep 23, 2024
2 parents 217b8ec + fccf785 commit feb0086
Show file tree
Hide file tree
Showing 36 changed files with 543 additions and 317 deletions.
10 changes: 10 additions & 0 deletions composition-js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG for `@apollo/composition`

## 2.9.1

### Patch Changes

- Fix bugs in composition when merging nulls in directive applications and when handling renames. ([#3134](https://github.com/apollographql/federation/pull/3134))

- Updated dependencies [[`b8e4ab5352a4dfd262af49493fdd42e86e5e3d99`](https://github.com/apollographql/federation/commit/b8e4ab5352a4dfd262af49493fdd42e86e5e3d99), [`e6c05b6c96023aa3dec79889431f8217fcb3806d`](https://github.com/apollographql/federation/commit/e6c05b6c96023aa3dec79889431f8217fcb3806d)]:
- @apollo/federation-internals@2.9.1
- @apollo/query-graphs@2.9.1

## 2.9.0

### Minor Changes
Expand Down
6 changes: 3 additions & 3 deletions composition-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apollo/composition",
"version": "2.10.0-alpha.1",
"version": "2.9.1",
"description": "Apollo Federation composition utilities",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -27,8 +27,8 @@
"access": "public"
},
"dependencies": {
"@apollo/federation-internals": "2.10.0-alpha.1",
"@apollo/query-graphs": "2.10.0-alpha.1"
"@apollo/federation-internals": "2.9.1",
"@apollo/query-graphs": "2.9.1"
},
"peerDependencies": {
"graphql": "^16.5.0"
Expand Down
37 changes: 37 additions & 0 deletions composition-js/src/__tests__/compose.demandControl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ describe('demand control directive composition', () => {
assertCompositionSuccess(result);
expect(result.hints).toEqual([]);

expect(result.schema.directive(`cost`)).toBeDefined();
expect(result.schema.directive(`listSize`)).toBeDefined();
expect(result.schema.directive(`cost__listSize`)).toBeUndefined();

const costDirectiveApplications = fieldWithCost(result)?.appliedDirectivesOf('cost');
expect(costDirectiveApplications?.toString()).toMatchString(`@cost(weight: 5)`);

Expand Down Expand Up @@ -773,5 +777,38 @@ describe('demand control directive extraction', () => {
}
`);
});

it('does not attempt to extract them to the subgraphs with similar spec URL', () => {
const subgraphA = {
name: 'subgraph-a',
typeDefs: asFed2SubgraphDocument(gql`
extend schema
@link(url: "https://specs.apollo.dev.foo.com/cost/v0.1")
@composeDirective(name: "@cost")
directive @cost(weight: Int!) on FIELD_DEFINITION
type Query {
a: Int @cost(weight: 1)
}
`)
};

const result = composeServices([subgraphA]);
assertCompositionSuccess(result);
const supergraph = Supergraph.build(result.supergraphSdl);

expect(supergraph.subgraphs().get(subgraphA.name)?.toString()).toMatchString(`
schema
${FEDERATION2_LINK_WITH_AUTO_EXPANDED_IMPORTS}
{
query: Query
}
type Query {
a: Int
}
`);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,19 @@ describe('composition of directive with non-trivial argument strategies', () =>
t: 2, k: 1, b: 4,
},
}, {
name: 'sum',
type: (schema: Schema) => new NonNullType(schema.intType()),
compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.SUM,
argValues: {
s1: { t: 3, k: 1 },
s2: { t: 2, k: 5, b: 4 },
},
resultValues: {
t: 5, k: 6, b: 4,
},
}, {
// NOTE: See the note for the SUM strategy in argumentCompositionStrategies.ts
// for more information on why this is commented out.
// name: 'sum',
// type: (schema: Schema) => new NonNullType(schema.intType()),
// compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.SUM,
// argValues: {
// s1: { t: 3, k: 1 },
// s2: { t: 2, k: 5, b: 4 },
// },
// resultValues: {
// t: 5, k: 6, b: 4,
// },
// }, {
name: 'intersection',
type: (schema: Schema) => new NonNullType(new ListType(new NonNullType(schema.stringType()))),
compositionStrategy: ARGUMENT_COMPOSITION_STRATEGIES.INTERSECTION,
Expand Down Expand Up @@ -219,7 +221,7 @@ describe('composition of directive with non-trivial argument strategies', () =>
const s = result.schema;

expect(directiveStrings(s.schemaDefinition, name)).toStrictEqual([
`@link(url: "https://specs.apollo.dev/${name}/v0.1", import: ["@${name}"])`
`@link(url: "https://specs.apollo.dev/${name}/v0.1")`
]);

const t = s.type('T') as ObjectType;
Expand Down
Loading

0 comments on commit feb0086

Please sign in to comment.