Skip to content

Commit cb41478

Browse files
authored
Update composition to v0.16.0 (#6665)
1 parent 7023429 commit cb41478

25 files changed

+89
-904
lines changed

.changeset/stale-humans-camp.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'hive': minor
3+
---
4+
5+
Update `@theguild/federation-composition` to `v0.16.0`.
6+
7+
- Support Apollo Federation `v2.7`, but without the progressive `@override`.
8+
- Support Apollo Federation `v2.8`, but without the `@context` and `@fromContext` directives.
9+
- Support Apollo Federation `v2.9`, including `@cost` and `@listSize` directives.

integration-tests/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@hive/schema": "workspace:*",
2222
"@hive/server": "workspace:*",
2323
"@hive/storage": "workspace:*",
24+
"@theguild/federation-composition": "0.16.0",
2425
"@trpc/client": "10.45.2",
2526
"@trpc/server": "10.45.2",
2627
"@types/async-retry": "1.4.8",

integration-tests/testkit/graphql.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
import { ExecutionResult, print } from 'graphql';
1+
import { ExecutionResult, parse, print } from 'graphql';
22
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3+
import { sortSDL } from '@theguild/federation-composition';
34
import { getServiceHost } from './utils';
45

6+
/**
7+
* Sorts the SDL of a supergraph schema and removes any extra whitespace.
8+
* Helps with schema assertions, especially the snapshot tests.
9+
* @param sdl The SDL of a supergraph schema.
10+
* @returns The normalized SDL.
11+
*/
12+
export function normalizeSupergraph(sdl: string): string {
13+
return print(sortSDL(parse(sdl, { noLocation: true })));
14+
}
15+
516
export async function execute<TResult, TVariables>(
617
params: {
718
document: TypedDocumentNode<TResult, TVariables>;

integration-tests/tests/schema/metadata.spec.ts

+35-75
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { normalizeSupergraph } from 'testkit/graphql';
12
import { getServiceHost } from 'testkit/utils';
23
import type { SchemaBuilderApi } from '@hive/schema';
34
import { createTRPCProxyClient, httpLink } from '@trpc/client';
@@ -71,96 +72,55 @@ describe('schema service can process metadata', async () => {
7172
});
7273

7374
test('@meta does not need to be in supergraph', () => {
74-
expect(result.supergraph).toMatchInlineSnapshot(`
75-
schema
76-
@link(url: "https://specs.apollo.dev/link/v1.0")
77-
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
78-
79-
80-
81-
82-
83-
@link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"])
84-
{
85-
query: Query
86-
87-
88-
}
89-
90-
91-
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
92-
93-
directive @join__field(
94-
graph: join__Graph
95-
requires: join__FieldSet
96-
provides: join__FieldSet
97-
type: String
98-
external: Boolean
99-
override: String
100-
usedOverridden: Boolean
101-
) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
102-
103-
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
104-
105-
directive @join__implements(
106-
graph: join__Graph!
107-
interface: String!
108-
) repeatable on OBJECT | INTERFACE
109-
110-
directive @join__type(
111-
graph: join__Graph!
112-
key: join__FieldSet
113-
extension: Boolean! = false
114-
resolvable: Boolean! = true
115-
isInterfaceObject: Boolean! = false
116-
) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
117-
118-
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
119-
120-
scalar join__FieldSet
121-
122-
123-
directive @link(
124-
url: String
125-
as: String
126-
for: link__Purpose
127-
import: [link__Import]
128-
) repeatable on SCHEMA
129-
130-
scalar link__Import
131-
132-
enum link__Purpose {
133-
"""
134-
\`SECURITY\` features provide metadata necessary to securely resolve fields.
135-
"""
136-
SECURITY
137-
138-
"""
139-
\`EXECUTION\` features provide metadata necessary for operation execution.
140-
"""
141-
EXECUTION
142-
}
75+
expect(result.supergraph).toBeDefined();
76+
expect(normalizeSupergraph(result.supergraph!)).toMatchInlineSnapshot(`
77+
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
14378
79+
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
14480
81+
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
14582
83+
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on INTERFACE | OBJECT
14684
85+
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on ENUM | INPUT_OBJECT | INTERFACE | OBJECT | SCALAR | UNION
14786
87+
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
14888
89+
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
14990
15091
enum join__Graph {
151-
FOO_GRAPHQL @join__graph(name: "foo.graphql", url: "")
152-
USER_GRAPHQL @join__graph(name: "user.graphql", url: "")
92+
FOO_GRAPHQL @join__graph(name: "foo.graphql", url: "")
93+
USER_GRAPHQL @join__graph(name: "user.graphql", url: "")
94+
}
95+
96+
enum link__Purpose {
97+
"""
98+
\`EXECUTION\` features provide metadata necessary for operation execution.
99+
"""
100+
EXECUTION
101+
"""
102+
\`SECURITY\` features provide metadata necessary to securely resolve fields.
103+
"""
104+
SECURITY
153105
}
154106
155-
type Query @join__type(graph: FOO_GRAPHQL) @join__type(graph: USER_GRAPHQL) {
156-
foo: String @join__field(graph: FOO_GRAPHQL)
157-
user: User @join__field(graph: USER_GRAPHQL)
107+
type Query @join__type(graph: FOO_GRAPHQL) @join__type(graph: USER_GRAPHQL) {
108+
foo: String @join__field(graph: FOO_GRAPHQL)
109+
user: User @join__field(graph: USER_GRAPHQL)
158110
}
159111
160-
type User @join__type(graph: USER_GRAPHQL) {
112+
type User @join__type(graph: USER_GRAPHQL) {
161113
id: ID!
162114
name: String
163115
}
116+
117+
scalar join__FieldSet
118+
119+
scalar link__Import
120+
121+
schema @link(for: EXECUTION, url: "https://specs.apollo.dev/join/v0.3") @link(import: ["@meta"], url: "https://specs.graphql-hive.com/hive/v1.0") @link(url: "https://specs.apollo.dev/link/v1.0") {
122+
query: Query
123+
}
164124
`);
165125
});
166126

packages/libraries/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@oclif/core": "^3.26.6",
6060
"@oclif/plugin-help": "6.0.22",
6161
"@oclif/plugin-update": "4.2.13",
62-
"@theguild/federation-composition": "0.15.0",
62+
"@theguild/federation-composition": "0.16.0",
6363
"colors": "1.4.0",
6464
"env-ci": "7.3.0",
6565
"graphql": "^16.8.1",

packages/libraries/federation-link-utils/README.md

-65
This file was deleted.

packages/libraries/federation-link-utils/package.json

-62
This file was deleted.

packages/libraries/federation-link-utils/src/index.ts

-75
This file was deleted.

0 commit comments

Comments
 (0)