Skip to content

Commit 8f1aca2

Browse files
committed
Initial commit
0 parents  commit 8f1aca2

File tree

130 files changed

+11928
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+11928
-0
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.{kt,kts}]
2+
indent_size=2
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Build pull request
2+
3+
on: pull_request
4+
5+
jobs:
6+
build-pull-request:
7+
runs-on: macos-latest
8+
9+
steps:
10+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
11+
- run: |
12+
./gradlew build
13+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
on:
2+
push:
3+
branches: [ main ]
4+
5+
jobs:
6+
publish-pages:
7+
runs-on: ubuntu-latest
8+
if: github.event.repository.fork == false
9+
10+
# Required for the `deploy-pages` action
11+
permissions:
12+
pages: write
13+
id-token: write
14+
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
17+
- run: |
18+
export JAVA_HOME=$JAVA_HOME_21_X64 # Remove when ubuntu-latest updates to Java 21
19+
./gradlew librarianStaticContent
20+
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa #v3.0.1
21+
with:
22+
path: "build/static"
23+
- uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e #v4.0.5
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
publish-release:
11+
runs-on: macos-latest
12+
13+
steps:
14+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
15+
- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2
16+
- run: |
17+
LIBRARIAN_RELEASE=true ./gradlew librarianPublishToMavenCentral
18+
env:
19+
LIBRARIAN_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
20+
LIBRARIAN_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
21+
LIBRARIAN_SIGNING_PRIVATE_KEY: ${{ secrets.SONATYPE_GPG_KEY }}
22+
LIBRARIAN_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.SONATYPE_GPG_KEY_PASSWORD }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish snapshot
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
jobs:
7+
publish-snapshot:
8+
runs-on: macos-latest
9+
10+
steps:
11+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
12+
- uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda #v3.4.2
13+
- run: |
14+
LIBRARIAN_VERSION_SHA1=$GITHUB_SHA ./gradlew librarianPublishToGcs
15+
./gradlew librarianPublishToSnapshots
16+
env:
17+
LIBRARIAN_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
18+
LIBRARIAN_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
19+
LIBRARIAN_GOOGLE_SERVICES_JSON: ${{ secrets.APOLLO_KOTLIN_GOOGLE_SERVICES_JSON }}

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
xcshareddata
2+
3+
.fleet
4+
.gradle
5+
6+
# Idea
7+
**/.idea/*
8+
!**/.idea/codeStyles
9+
!**/.idea/icon.png
10+
!**/.idea/runConfigurations
11+
!**/.idea/scopes
12+
!**/.idea/dictionaries
13+
*.iml
14+
15+
# Generated files
16+
build
17+
/reports
18+
.kotlin
19+
.build/
20+
DerivedData/
21+
22+
# Place where the Android SDK path is set
23+
local.properties
24+
25+
# Secret used by sample apps
26+
github_token
27+
28+
# XCode
29+
xcuserdata
30+
project.xcworkspace
31+
32+
# Mac OS Finder
33+
.DS_Store
34+
Thumbs.db
35+
db.json
36+
*.log
37+
38+
# Docs
39+
node_modules/
40+
/docs/public
41+
/docs/.cache
42+
!docs/public/_redirects
43+
.deploy*/
44+
docs.json
45+
**/.project
46+
.vscode/**
47+
**/bin
48+
.sqldelight
49+
50+
# Local Netlify folder
51+
.netlify
52+
53+
# Apollo iOS
54+
apollo-ios-cli
55+
56+
release.jks
57+
keystore.properties

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016-2025 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Apollo Kotlin Compiler Plugin
2+
3+
The Apollo Kotlin Compiler Plugin is a Kotlin compiler plugin to work with GraphQL operations.
4+
5+
The Apollo Kotlin Compiler Plugin makes it possible to colocate your GraphQL queries in your `.kt` Kotlin files.
6+
7+
> [!WARNING]
8+
> This project is under construction.
9+
10+
## Get Started
11+
12+
Add the `com.apollographql.kotlin.compiler.plugin` Gradle plugin to your `build.gradle.kts` files:
13+
14+
```kotlin
15+
plugins {
16+
id("org.jetbrains.kotlin.jvm").version("2.2.20-RC")
17+
id("com.apollographql.kotlin.compiler.plugin").version("2.2.20-RC-0.0.0-SNAPSHOT")
18+
}
19+
20+
apolloKotlinCompilerPlugin {
21+
// Configure your schema
22+
schemaFile.set(file("schema.graphqls"))
23+
// Enable Apollo Kotlin compatibility mode to use the generated models with
24+
// your existing `ApolloClient`
25+
compat.set(true)
26+
}
27+
28+
dependencies {
29+
// The client
30+
implementation("com.apollographql.apollo:apollo-runtime:5.0.0-alpha.2")
31+
// The Kotlin compiler plugin runtime
32+
implementation("com.apollographql.kotlin:runtime-compat:2.2.20-RC-0.0.0-SNAPSHOT")
33+
}
34+
```
35+
36+
To execute an operation, write a `@Query` class:
37+
38+
```kotlin
39+
@Query("""
40+
query GetSessions {
41+
sessions {
42+
start
43+
end
44+
title
45+
speakers {
46+
name
47+
}
48+
}
49+
}
50+
51+
""")
52+
class GetSessions
53+
```
54+
55+
The compiler plugins automatically makes your class an instance of `Query` and generates nested models:
56+
57+
* `Data`
58+
* `Session`
59+
* `Speaker`
60+
61+
Use them with `ApolloClient` ([documentation](https://www.apollographql.com/docs/kotlin/essentials/queries)):
62+
63+
```kotlin
64+
apolloClient.query(GetScheduleItemsQuery()).toFlow().collect {
65+
it.data?.sessions?.forEach {
66+
println(it.title)
67+
}
68+
}
69+
```
70+
71+
Output:
72+
```
73+
Community Update 2025: Growing in the Open
74+
GraphQL at Meta
75+
How To Use Fragments (They're Not for Re-use!)
76+
Fixing GraphQL's Biggest Mistake in 512 Bytes
77+
...
78+
```
79+

build-logic/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
alias(libs.plugins.kgp.jvm)
3+
}
4+
5+
group = "com.apollographql.kotlin.build"
6+
7+
dependencies {
8+
implementation(libs.kgp)
9+
implementation(libs.ksp)
10+
implementation(libs.librarian)
11+
implementation(libs.compat.patrouille)
12+
implementation(libs.gratatouille)
13+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[versions]
2+
compat-patrouille = "0.0.0"
3+
gratatouille = "0.1.1-SNAPSHOT-cc0251b8b2f1a34608de3c3542056ebd2689ec89"
4+
kgp = "2.2.20-RC"
5+
ksp = "2.2.20-RC-2.0.2"
6+
kctf = "2.2.20-RC-0.0.1-SNAPSHOT-1ec706847053d49bc9a048628a34a3da16373bf6"
7+
kct = "0.8.0"
8+
okio = "3.16.0"
9+
apollo = "5.0.0-alpha.2"
10+
11+
[libraries]
12+
apollo-ast = { module = "com.apollographql.apollo:apollo-ast", version.ref = "apollo" }
13+
apollo-api = { module = "com.apollographql.apollo:apollo-api", version.ref = "apollo" }
14+
compat-patrouille = { module = "com.gradleup.compat.patrouille:com.gradleup.compat.patrouille.gradle.plugin", version.ref = "compat-patrouille" }
15+
coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2"
16+
coroutines-test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2"
17+
gradle-api = "dev.gradleplugins:gradle-api:8.11.1"
18+
gratatouille = { module = "com.gradleup.gratatouille:gratatouille-gradle-plugin", version.ref = "gratatouille" }
19+
kgp = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kgp" }
20+
kct = { module = "dev.zacsweers.kctfork:core", version.ref = "kct" }
21+
kotlin-compilerEmbeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kgp" }
22+
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
23+
kctf-gradle-plugin = { module = "com.gradleup.kctf:kctf-gradle-plugin", version.ref = "kctf" }
24+
kctf-runtime = { module = "com.gradleup.kctf:kctf-runtime", version.ref = "kctf" }
25+
ksp = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }
26+
librarian = "com.gradleup.librarian:com.gradleup.librarian.gradle.plugin:0.1.1-SNAPSHOT-44a36034d83f8ba9c9177653f29df3dea933fc3f"
27+
okio = { group = "com.squareup.okio", name = "okio", version.ref = "okio" }
28+
cast = "net.mbonnin.cast:cast:0.0.1"
29+
30+
[plugins]
31+
kgp-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kgp" }

0 commit comments

Comments
 (0)