Skip to content

Commit 38f9d67

Browse files
authored
Update v5 migration guide to include downloadApolloSchema (#6745)
* Update v5 migration guide to include downloadApolloSchema * wording
1 parent 800a0a7 commit 38f9d67

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

docs/source/migration/5.0.mdx

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ In most cases, bumping the version should be transparent. The exceptions are:
1111
- Symbols that were `DeprecationLevel.ERROR` in v4 are now removed. Remove all your deprecated usages before migrating to v5.
1212
- `apollo-compiler` is still considered experimental. You will need to update your [Apollo Compiler Plugins](https://www.apollographql.com/docs/kotlin/advanced/compiler-plugins).
1313

14-
We tried hard to minimize the impact of the binary changes so that running code compiled for v4 will run with v5. But the occasional incompatibility may happen. In that case, the incompatible libraries will need to compile against v5 and make a new release.
14+
Read below for more details.
1515

16-
## Removed `apollo-gradle-plugin-external` and `com.apollographql.apollo.external`
16+
## `apollo-gradle-plugin-external`
1717

18-
The Apollo Gradle Plugin [now uses classloader isolation](https://github.com/apollographql/apollo-kotlin/pull/6524) and does not use R8 to relocate dependencies anymore. As a result, the `apollo-gradle-plugin-external` artifact and the `com.apollographql.apollo.external` plugins have been removed. You should use `apollo-gradle-plugin` and `com.apollographql.apollo` instead:
18+
The Apollo Gradle Plugin [now uses classloader isolation](https://github.com/apollographql/apollo-kotlin/pull/6524) and does not use R8 to relocate dependencies anymore. As a result, the `apollo-gradle-plugin-external` artifact and the `com.apollographql.apollo.external` plugins are not used anymore and now point to an empty plugin. You should use `apollo-gradle-plugin` and `com.apollographql.apollo` instead:
1919

2020
```kotlin
2121
// Replace
@@ -31,13 +31,13 @@ plugins {
3131
}
3232
```
3333

34-
## Removed `Service.operationOutputGenerator` and `Service.operationIdGenerator`
34+
## `apollo-gradle-plugin`
3535

36-
While running your `OperationOutputGenerator` directly in your build script classpath was convenient, it required the compiler code to run completely in the global buildscript classpath. This created numerous issues such as incompatible dependencies and/or unneeded build invalidations.
36+
### `operationOutputGenerator` and `operationIdGenerator` are removed.
3737

38-
To mitigate the impact of incompatible dependencies, Apollo Kotlin 4 used to shadow and relocate all its dependencies, which came with additional issues: increased build times, weird stack traces and larger plugin size.
38+
While running your `OperationOutputGenerator` directly in your build script classpath was convenient, it required the compiler code to run completely in the global buildscript classpath. This created many issues such as incompatible dependencies and/or unneeded build invalidations.
3939

40-
Apollo Kotlin v5 instead runs its compiler in isolated classloaders, meaning generating the ids now needs to happen in that same classloader.
40+
The v5 Apollo Gradle plugin runs the Apollo compiler in isolated classloaders, meaning generating the ids needs to happen in that same classloader using the `ServiceLoader` API.
4141

4242
To do so, use `ApolloCompilerPlugin`:
4343

@@ -56,14 +56,42 @@ class MyPlugin : ApolloCompilerPlugin {
5656

5757
Read more in the [persisted queries](https://www.apollographql.com/docs/kotlin/v5/advanced/persisted-queries) and [compiler plugins](https://www.apollographql.com/docs/kotlin/v5/advanced/compiler-plugins) pages.
5858

59+
### `downloadApolloSchema` is removed
5960

60-
## Removed ApolloIdlingResource
61+
Apollo Kotlin 4 allowed downloading a schema with a `downloadApolloSchema` Gradle task. This task is now removed.
6162

62-
Apollo Kotlin 5 removes `ApolloIdlingResource`. `IdlingResource` usage has been slowly decreasing and there are now better alternatives to do your testing.
63+
For single-shot downloads of a schema during development, use the [Apollo Kotlin CLI](https://github.com/apollographql/apollo-kotlin-cli). It is much faster (no Gradle configuration), comes with interactive help and soon autocomplete scripts.
6364

64-
For a good overview of alternative solutions, we recommend [this article from Jose Alcérreca](https://medium.com/androiddevelopers/alternatives-to-idling-resources-in-compose-tests-8ae71f9fc473).
65+
Alternatively, configure [your introspection block](https://www.apollographql.com/docs/kotlin/advanced/plugin-recipes#downloading-a-schema). Doing so documents how to update the schema for other developers and makes it easy to update the schema without passing extra arguments.
6566

66-
## Using `@nonnull` is now an error
67+
```kotlin
68+
apollo {
69+
service("service") {
70+
packageName.set("com.example")
71+
72+
// This creates a downloadServiceApolloSchemaFromIntrospection task
73+
introspection {
74+
endpointUrl.set("https://example.com/graphql/endpoint")
75+
// The path is interpreted relative to the current project
76+
schemaFile.set(file("src/main/graphql/schema.graphqls"))
77+
}
78+
}
79+
}
80+
81+
// You can create a shorthand lifecycle task name
82+
tasks.register("downloadSchema") {
83+
dependsOn("downloadServiceApolloSchemaFromIntrospection")
84+
}
85+
```
86+
## `apollo-idling-resource`
87+
88+
Apollo Kotlin 5 removes the `apollo-idling-resource` artifact. Usage of `ApolloIdlingResource` has been decreasing, and better alternatives for testing are now available.
89+
90+
For a good overview of alternative solutions, we recommend reading [this article from Jose Alcérreca](https://medium.com/androiddevelopers/alternatives-to-idling-resources-in-compose-tests-8ae71f9fc473).
91+
92+
## `apollo-compiler`
93+
94+
### `@nonnull` is an error
6795

6896
Apollo Kotlin 4 had a `@nonnull` client directive to force generating fields as non-null.
6997

@@ -98,9 +126,9 @@ query GetUser {
98126
You can read more in the ["handling nullability" page](https://www.apollographql.com/docs/kotlin/advanced/nullability).
99127

100128

101-
## `apollo-http-cache` is deprecated
129+
## `apollo-http-cache`
102130

103-
Apollo Kotlin 5 removes the `apollo-http-cache` artifact. Instead, it uses the existing OkHttp cache using [cacheUrlOverride](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-request/-builder/cache-url-override.html).
131+
`apollo-http-cache` is now deprecated. Instead, it uses the existing OkHttp cache using [cacheUrlOverride](https://square.github.io/okhttp/5.x/okhttp/okhttp3/-request/-builder/cache-url-override.html).
104132

105133
You can remove the `apollo-http-cache` artifact:
106134

@@ -168,8 +196,6 @@ apolloClient.query(query).httpFetchPolicy(HttpFetchPolicy.CacheOnly)
168196
apolloClient.query(query).addHttpHeader("cache-control", "no-cache")
169197
```
170198

171-
### Limitations
172-
173199
We believe this new caching scheme is simpler and more aligned with the rest of the ecosystem, but there are important differences with the previous scheme:
174200

175201
- There is no equivalent to `NetworkFirst` and/or `httpExpireTimeout()`.

0 commit comments

Comments
 (0)