Skip to content

Commit 54610c7

Browse files
authored
add Apollo Federation Subgraph Compatibility tests (ExpediaGroup#1628)
* add Apollo Federation Subgraph Compatibility tests Adds new test project that implements reference federated schema that is used for testing library compatibility against [Apollo Federation Subgraph Specifcation](https://www.apollographql.com/docs/federation/subgraph-spec/). Configured a [GH action](https://github.com/apollographql/federation-subgraph-compatibility) that executes compatibility tests from [apollographql/apollo-federation-subgraph-compatibility](https://github.com/apollographql/apollo-federation-subgraph-compatibility) testing repository. * trigger fed compatibility workflow only on PRs modifying fed logic * add GH token and enable version catalog
1 parent da9c92f commit 54610c7

24 files changed

+955
-0
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ jobs:
2020
needs: build-libraries
2121
uses: ./.github/workflows/federation-composition.yml
2222

23+
federation-compatibility:
24+
needs: build-libraries
25+
uses: ./.github/workflows/federation-compatibility.yml
26+
secrets:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
2329
release-notes:
2430
timeout-minutes: 10
2531
runs-on: ubuntu-latest
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Federation Compatibility
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
token:
7+
required: true
8+
9+
jobs:
10+
compatibility:
11+
timeout-minutes: 30
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: integration/federation-compatibility
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Validate Gradle wrapper
21+
uses: gradle/wrapper-validation-action@v1
22+
23+
- name: Set up Java 11
24+
uses: actions/setup-java@v3
25+
with:
26+
java-version: 11
27+
distribution: 'zulu'
28+
29+
- name: Set up Gradle cache
30+
uses: gradle/gradle-build-action@v2
31+
32+
- name: Build compatibility app with Gradle
33+
run: ./gradlew bootJar graphqlGenerateSDL
34+
35+
- name: Compatibility Test
36+
uses: apollographql/federation-subgraph-compatibility@v1
37+
with:
38+
compose: 'integration/federation-compatibility/docker-compose.yaml'
39+
schema: 'integration/federation-compatibility/build/schema.graphql'
40+
debug: true
41+
token: ${{ secrets.token }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Pull Request Federation Check
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- master
7+
paths:
8+
- 'generator/graphql-kotlin-federation/**'
9+
10+
jobs:
11+
federation-compatibility:
12+
uses: ./.github/workflows/federation-compatibility.yml
13+
secrets:
14+
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM gradle:7.6.0-jdk17
2+
3+
EXPOSE 4001
4+
RUN mkdir /app
5+
6+
COPY build/federation-compatibility.jar /app/app.jar
7+
8+
ENTRYPOINT ["java", "-jar","/app/app.jar"]
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Apollo Federation Subgraph Compatibility
2+
3+
This is a reference implementation used for testing `graphql-kotlin` compatibility against [Apollo Federation Subgraph Specification](https://www.apollographql.com/docs/federation/subgraph-spec/).
4+
5+
This project implements following reference schema:
6+
7+
```graphql
8+
extend schema
9+
@link(
10+
url: "https://specs.apollo.dev/federation/v2.0",
11+
import: [
12+
"@extends",
13+
"@external",
14+
"@key",
15+
"@inaccessible",
16+
"@override",
17+
"@provides",
18+
"@requires",
19+
"@shareable",
20+
"@tag"
21+
]
22+
)
23+
24+
type Product
25+
@key(fields: "id")
26+
@key(fields: "sku package")
27+
@key(fields: "sku variation { id }") {
28+
id: ID!
29+
sku: String
30+
package: String
31+
variation: ProductVariation
32+
dimensions: ProductDimension
33+
createdBy: User @provides(fields: "totalProductsCreated")
34+
notes: String @tag(name: "internal")
35+
research: [ProductResearch!]!
36+
}
37+
38+
type DeprecatedProduct @key(fields: "sku package") {
39+
sku: String!
40+
package: String!
41+
reason: String
42+
createdBy: User
43+
}
44+
45+
type ProductVariation {
46+
id: ID!
47+
}
48+
49+
type ProductResearch @key(fields: "study { caseNumber }") {
50+
study: CaseStudy!
51+
outcome: String
52+
}
53+
54+
type CaseStudy {
55+
caseNumber: ID!
56+
description: String
57+
}
58+
59+
type ProductDimension @shareable {
60+
size: String
61+
weight: Float
62+
unit: String @inaccessible
63+
}
64+
65+
extend type Query {
66+
product(id: ID!): Product
67+
deprecatedProduct(sku: String!, package: String!): DeprecatedProduct @deprecated(reason: "Use product query instead")
68+
}
69+
70+
extend type User @key(fields: "email") {
71+
averageProductsCreatedPerYear: Int @requires(fields: "totalProductsCreated yearsOfEmployment")
72+
email: ID! @external
73+
name: String @override(from: "users")
74+
totalProductsCreated: Int @external
75+
yearsOfEmployment: Int! @external
76+
}
77+
```
78+
79+
See [apollographql/apollo-federation-subgraph-compatibility](https://github.com/apollographql/apollo-federation-subgraph-compatibility)
80+
for additional details about expected data sets and executed tests.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import com.expediagroup.graphql.plugin.gradle.graphql
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
buildscript {
5+
repositories {
6+
mavenCentral()
7+
mavenLocal {
8+
content {
9+
includeGroup("com.expediagroup")
10+
}
11+
}
12+
}
13+
}
14+
15+
@Suppress("DSL_SCOPE_VIOLATION") // TODO: remove once KTIJ-19369 / Gradle#22797 is fixed
16+
plugins {
17+
id("com.expediagroup.graphql")
18+
alias(libs.plugins.spring.boot)
19+
alias(libs.plugins.kotlin.jvm)
20+
alias(libs.plugins.kotlin.spring)
21+
}
22+
23+
group = "com.expediagroup.federation.compatibility"
24+
java.sourceCompatibility = JavaVersion.VERSION_11
25+
26+
repositories {
27+
mavenCentral()
28+
mavenLocal {
29+
content {
30+
includeGroup("com.expediagroup")
31+
}
32+
}
33+
}
34+
35+
dependencies {
36+
implementation(libs.kotlin.reflect)
37+
implementation(libs.kotlin.stdlib)
38+
implementation("com.expediagroup", "graphql-kotlin-spring-server")
39+
graphqlSDL("com.expediagroup", "graphql-kotlin-federated-hooks-provider")
40+
}
41+
42+
tasks.withType<KotlinCompile> {
43+
kotlinOptions {
44+
freeCompilerArgs = listOf("-Xjsr305=strict")
45+
jvmTarget = "11"
46+
}
47+
}
48+
49+
tasks.withType<Test> {
50+
useJUnitPlatform()
51+
}
52+
53+
graphql {
54+
schema {
55+
packages = listOf("com.expediagroup.federation.compatibility")
56+
}
57+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
products:
3+
# must be relative to the root of the project
4+
build: integration/federation-compatibility
5+
ports:
6+
- 4001:4001
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)