Skip to content

Commit 60ce9ae

Browse files
author
sjin
committed
Update fed verisons
1 parent 30071bc commit 60ce9ae

File tree

23 files changed

+97
-41
lines changed

23 files changed

+97
-41
lines changed

examples/client/server/src/main/kotlin/com/expediagroup/graphql/examples/client/server/FederatedQuery.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ data class ProductVariation(
9696
data class User(
9797
@ExternalDirective
9898
val email: String,
99-
@OverrideDirective(from = "users")
99+
@OverrideDirective(from = "users", label = "Migrating name field")
100100
val name: String,
101101
@ExternalDirective
102102
val totalProductsCreated: Int? = null

examples/federation/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
router:
3-
image: ghcr.io/apollographql/router:v1.40.0
3+
image: ghcr.io/apollographql/router:v1.47.0
44
volumes:
55
- ./router.yaml:/dist/config/router.yaml
66
- ./supergraph.graphql:/dist/config/supergraph.graphql

examples/federation/supergraph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
federation_version: =2.6.3
1+
federation_version: =2.7.5
22
subgraphs:
33
products:
44
routing_url: http://products:8080/graphql

generator/graphql-kotlin-federation/src/main/kotlin/com/expediagroup/graphql/generator/federation/FederatedSchemaGeneratorHooks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

generator/graphql-kotlin-federation/src/main/kotlin/com/expediagroup/graphql/generator/federation/directives/LinkDirective.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ const val LINK_SPEC_URL_PREFIX = "$APOLLO_SPEC_URL/$LINK_SPEC"
3232
const val LINK_SPEC_LATEST_URL = "$LINK_SPEC_URL_PREFIX/v$LINK_SPEC_LATEST_VERSION"
3333

3434
const val FEDERATION_SPEC = "federation"
35-
const val FEDERATION_SPEC_LATEST_VERSION = "2.6"
35+
const val FEDERATION_SPEC_LATEST_VERSION = "2.7"
3636
const val FEDERATION_SPEC_URL_PREFIX = "$APOLLO_SPEC_URL/$FEDERATION_SPEC"
3737
const val FEDERATION_SPEC_LATEST_URL = "$FEDERATION_SPEC_URL_PREFIX/v$FEDERATION_SPEC_LATEST_VERSION"
3838

generator/graphql-kotlin-federation/src/main/kotlin/com/expediagroup/graphql/generator/federation/directives/OverrideDirective.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,9 +46,11 @@ import graphql.schema.GraphQLNonNull
4646
description = OVERRIDE_DIRECTIVE_DESCRIPTION,
4747
locations = [DirectiveLocation.FIELD_DEFINITION]
4848
)
49-
annotation class OverrideDirective(val from: String)
49+
annotation class OverrideDirective(val from: String, val label: String = "")
5050

5151
internal const val OVERRIDE_DIRECTIVE_NAME = "override"
52+
internal const val OVERRIDE_DIRECTIVE_FROM_PARAM = "from"
53+
internal const val OVERRIDE_DIRECTIVE_LABEL_PARAM = "label"
5254
private const val OVERRIDE_DIRECTIVE_DESCRIPTION = "Overrides fields resolution logic from other subgraph. Used for migrating fields from one subgraph to another."
5355

5456
/**
@@ -61,16 +63,16 @@ internal fun overrideDirectiveDefinition(): graphql.schema.GraphQLDirective {
6163
.validLocation(DirectiveLocation.FIELD_DEFINITION)
6264
.argument(
6365
GraphQLArgument.newArgument()
64-
.name("from")
66+
.name(OVERRIDE_DIRECTIVE_FROM_PARAM)
6567
.description("Name of the subgraph to override field resolution")
6668
.type(GraphQLNonNull(Scalars.GraphQLString))
6769
.build()
6870
)
6971

7072
builder.argument(
7173
GraphQLArgument.newArgument()
72-
.name("label")
73-
.description("The value must follow the format of 'percent(number)'. Enterprise feature available in Federation 2.7+.")
74+
.name(OVERRIDE_DIRECTIVE_LABEL_PARAM)
75+
.description("The value must follow the format of 'percent(number)'")
7476
.type(Scalars.GraphQLString)
7577
.build()
7678
)
@@ -93,14 +95,14 @@ internal fun graphql.schema.GraphQLDirective.toAppliedOverrideDirective(directiv
9395
val builder = GraphQLAppliedDirective.newDirective()
9496
.name(this.name)
9597
.argument(GraphQLAppliedDirectiveArgument.newArgument()
96-
.name("from")
98+
.name(OVERRIDE_DIRECTIVE_FROM_PARAM)
9799
.type(GraphQLNonNull(Scalars.GraphQLString))
98100
.valueProgrammatic(overrideDirective.from)
99101
.build())
100102

101103
if (!label.isNullOrEmpty()) {
102104
builder.argument(GraphQLAppliedDirectiveArgument.newArgument()
103-
.name("label")
105+
.name(OVERRIDE_DIRECTIVE_LABEL_PARAM)
104106
.type(Scalars.GraphQLString)
105107
.valueProgrammatic(label)
106108
.build())

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/FederatedSchemaGeneratorTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ class FederatedSchemaGeneratorTest {
3434
fun `verify can generate federated schema`() {
3535
val expectedSchema =
3636
"""
37-
schema @link(import : ["@external", "@key", "@provides", "@requires", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.6"){
37+
schema @link(import : ["@external", "@key", "@provides", "@requires", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.7"){
3838
query: Query
3939
}
4040
@@ -159,7 +159,7 @@ class FederatedSchemaGeneratorTest {
159159
fun `verify generator does not add federation queries for non-federated schemas`() {
160160
val expectedSchema =
161161
"""
162-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
162+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
163163
query: Query
164164
}
165165
@@ -218,7 +218,7 @@ class FederatedSchemaGeneratorTest {
218218
fun `verify a schema with self nested query still works`() {
219219
val expectedSchema =
220220
"""
221-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
221+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
222222
query: Query
223223
}
224224

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/directives/compose/ComposeDirectiveTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ class ComposeDirectiveTest {
4343
fun `verify we can generate valid schema with @composeDirective`() {
4444
val expectedSchema =
4545
"""
46-
schema @composeDirective(name : "custom") @link(as : "myspec", import : ["@custom"], url : "https://www.myspecs.dev/myspec/v1.0") @link(import : ["@composeDirective", "@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.6"){
46+
schema @composeDirective(name : "custom") @link(as : "myspec", import : ["@custom"], url : "https://www.myspecs.dev/myspec/v1.0") @link(import : ["@composeDirective", "@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.7"){
4747
query: Query
4848
}
4949

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/directives/contact/ContactDirectiveTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ class ContactDirectiveTest {
3030
fun `verify we can import federation spec using custom @link`() {
3131
val expectedSchema =
3232
"""
33-
schema @contact(description : "Send emails to [email protected]", name : "My Team Name", url : "https://myteam.slack.com/room") @link(url : "https://specs.apollo.dev/federation/v2.6"){
33+
schema @contact(description : "Send emails to [email protected]", name : "My Team Name", url : "https://myteam.slack.com/room") @link(url : "https://specs.apollo.dev/federation/v2.7"){
3434
query: Query
3535
}
3636

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/directives/link/LinkDirectiveTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ class LinkDirectiveTest {
4545
fun `verify we can import federation spec using custom @link`() {
4646
val expectedSchema =
4747
"""
48-
schema @link(as : "fed", import : [{name : "@key", as : "@myKey"}], url : "https://specs.apollo.dev/federation/v2.6"){
48+
schema @link(as : "fed", import : [{name : "@key", as : "@myKey"}], url : "https://specs.apollo.dev/federation/v2.7"){
4949
query: Query
5050
}
5151

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/directives/override/OverrideDirectiveTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2025 Expedia, Inc
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.expediagroup.graphql.generator.federation.directives.override
218

319
import com.expediagroup.graphql.generator.TopLevelObject

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/directives/policy/PolicyDirectiveTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ class PolicyDirectiveTest {
3535
fun `verify we can import federation spec using custom @link`() {
3636
val expectedSchema =
3737
"""
38-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
38+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
3939
query: Query
4040
}
4141

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/directives/requiresscope/RequiresScopesDirectiveTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ class RequiresScopesDirectiveTest {
3535
fun `verify we can import federation spec using custom @link`() {
3636
val expectedSchema =
3737
"""
38-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
38+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
3939
query: Query
4040
}
4141

generator/graphql-kotlin-federation/src/test/kotlin/com/expediagroup/graphql/generator/federation/execution/ServiceQueryResolverTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ import kotlin.test.assertNotNull
4242

4343
const val BASE_SERVICE_SDL =
4444
"""
45-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
45+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
4646
query: Query
4747
}
4848
@@ -70,7 +70,7 @@ scalar link__Import
7070

7171
const val FEDERATED_SERVICE_SDL_V2 =
7272
"""
73-
schema @link(import : ["@external", "@key", "@provides", "@requires", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.6"){
73+
schema @link(import : ["@external", "@key", "@provides", "@requires", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.7"){
7474
query: Query
7575
}
7676

integration/gradle-plugin-integration-tests/src/integration/resources/sdl/custom.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
1+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
22
query: Query
33
}
44

integration/gradle-plugin-integration-tests/src/integration/resources/sdl/federated.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
1+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
22
query: Query
33
}
44

integration/maven-plugin-integration-tests/integration/generate-sdl-federated/src/test/kotlin/com/expediagroup/graphql/plugin/maven/GenerateSDLMojoTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ class GenerateSDLMojoTest {
3636
assertTrue(schemaFile.exists(), "schema file was generated")
3737

3838
val expectedSchema = """
39-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
39+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
4040
query: Query
4141
}
4242

integration/maven-plugin-integration-tests/integration/generate-sdl-hooks/src/test/kotlin/com/expediagroup/graphql/plugin/maven/GenerateSDLMojoTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ class GenerateSDLMojoTest {
3636
assertTrue(schemaFile.exists(), "schema file was generated")
3737

3838
val expectedSchema = """
39-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
39+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
4040
query: Query
4141
}
4242

plugins/schema/graphql-kotlin-sdl-generator/src/integrationTest/kotlin/com/expediagroup/graphql/plugin/schema/GenerateCustomSDLTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Expedia, Inc
2+
* Copyright 2025 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ class GenerateCustomSDLTest {
2525
fun `verify we can generate SDL using custom hooks provider`() {
2626
val expectedSchema =
2727
"""
28-
schema @link(url : "https://specs.apollo.dev/federation/v2.6"){
28+
schema @link(url : "https://specs.apollo.dev/federation/v2.7"){
2929
query: Query
3030
}
3131

website/docs/schema-generator/federation/apollo-federation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ toFederatedSchema(
9191
will generate
9292

9393
```graphql
94-
schema @link(import : ["@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.6"){
94+
schema @link(import : ["@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.7"){
9595
query: Query
9696
}
9797

website/versioned_docs/version-7.x.x/schema-generator/federation/apollo-federation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ toFederatedSchema(
119119
will generate
120120

121121
```graphql
122-
schema @link(import : ["@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.6"){
122+
schema @link(import : ["@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.7"){
123123
query: Query
124124
}
125125

website/versioned_docs/version-8.x.x/schema-generator/federation/apollo-federation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ toFederatedSchema(
9191
will generate
9292

9393
```graphql
94-
schema @link(import : ["@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.6"){
94+
schema @link(import : ["@key", "FieldSet"], url : "https://specs.apollo.dev/federation/v2.7"){
9595
query: Query
9696
}
9797

website/versioned_docs/version-8.x.x/schema-generator/federation/federated-directives.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,44 @@ type Product @key(fields: "id") {
478478
}
479479
```
480480

481+
## progressive `@override` directive
482+
483+
:::info
484+
Available since Federation v2.0
485+
:::
486+
487+
```graphql
488+
directive @override(from: String!, label: String) on FIELD_DEFINITION
489+
```
490+
491+
The progressive @override feature enables the gradual, progressive deployment of a subgraph with an @override field. As a subgraph developer, you can customize the percentage of traffic that the overriding and overridden subgraphs each resolve for a field. Please read mmore about the [progressive @override feature](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/reference/directives) in the Apollo Router documentation.
492+
493+
:::caution
494+
It is an Enterprise feature of the GraphOS Router and requires an organization with a GraphOS Enterprise plan.
495+
Only one subgraph can `@override` any given field. If multiple subgraphs attempt to `@override` the same field, a composition error occurs.
496+
:::
497+
498+
#### Example
499+
500+
Given `SubgraphA`:
501+
502+
```graphql
503+
type Product @key(fields: "id") {
504+
id: String!
505+
description: String!
506+
}
507+
```
508+
509+
We can override the `description` field resolution in `SubgraphB`:
510+
511+
```graphql
512+
type Product @key(fields: "id") {
513+
id: String!
514+
name: String!
515+
description: String! @override(from: "SubgraphA", label: "percent(1)")
516+
}
517+
```
518+
481519
## `@policy` directive
482520

483521
:::info

0 commit comments

Comments
 (0)