Skip to content

Commit 75cc280

Browse files
authored
Add 5.0.0-alpha.0 and migration guide draft (#6593)
1 parent 11342a2 commit 75cc280

File tree

2 files changed

+127
-12
lines changed

2 files changed

+127
-12
lines changed

CHANGELOG.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,54 @@ Change Log
22
==========
33

44
# Next version
5+
# Version 5.0.0-alpha.0
6+
7+
This is the first alpha release of version 5.0.0. Previous `DeprecationLevel.WARNING` are turned into `DeprecationLevel.ERROR`. Previous `DeprecationLevel.ERROR` are removed.
8+
9+
For details about how to migrate, read the [migration guide draft](https://www.apollographql.com/docs/kotlin/v5/migration/5.0). This migration guide is still work in progress. Feedbacks are welcome as you try the new version!
10+
11+
**Infrastructure**:
12+
13+
* [breaking] Remove ApolloIdlingResource ([#6492](https://github.com/apollographql/apollo-kotlin/pull/6492))
14+
* [breaking] Remove PackageNameGenerator and OperationOutputGenerator, replaced by compiler plugins ([#6494](https://github.com/apollographql/apollo-kotlin/pull/6494))
15+
* [breaking] Move internal testing code to an unpublished module ([#6449](https://github.com/apollographql/apollo-kotlin/pull/6449))
16+
* [upgrade] Bump ktor to 3.1.2 ([#6465](https://github.com/apollographql/apollo-kotlin/pull/6465))
17+
* [breaking] Update deprecations for v5 ([#6496](https://github.com/apollographql/apollo-kotlin/pull/6496))
18+
* [new] Move IJ plugin to its own repository ([#6574](https://github.com/apollographql/apollo-kotlin/pull/6574))
19+
* [new] Switch publication to the central portal ([#6581](https://github.com/apollographql/apollo-kotlin/pull/6581))
20+
21+
Gradle
22+
* [fix] Do not generate the version as const ([#6563](https://github.com/apollographql/apollo-kotlin/pull/6563))
23+
* [new] Switch the gradle plugin to gratatouille ([#6524](https://github.com/apollographql/apollo-kotlin/pull/6524))
24+
* [fix] Remove checkApolloVersion ([#6569](https://github.com/apollographql/apollo-kotlin/pull/6569))
25+
* [new] Introspection: add a hint that more details are available in the exception cause. ([#6590](https://github.com/apollographql/apollo-kotlin/pull/6590))
26+
27+
**Compiler**:
28+
29+
* [new] Add schema-transform API ([#6450](https://github.com/apollographql/apollo-kotlin/pull/6450))
30+
* [new] Allow to generate Data Builders outside the main source set ([#6485](https://github.com/apollographql/apollo-kotlin/pull/6485))
31+
* [breaking] Using @nonnull is now an error ([#6499](https://github.com/apollographql/apollo-kotlin/pull/6499))
32+
* [fix] Ignore scalars/enums in checkCapitalizedFields ([#6502](https://github.com/apollographql/apollo-kotlin/pull/6502))
33+
* [fix] Call DocumentTransform.transform after adding required fields ([#6510](https://github.com/apollographql/apollo-kotlin/pull/6510))
34+
* [fix] Add key fields to selections even when they're already selected with an alias ([#6503](https://github.com/apollographql/apollo-kotlin/pull/6503))
35+
* [fix] Transform the GraphQL documents before running validation ([#6511](https://github.com/apollographql/apollo-kotlin/pull/6511))
36+
* [new] Add key fields of possible types of interfaces and fragments ([#6515](https://github.com/apollographql/apollo-kotlin/pull/6515))
37+
* [new] Allow to register multiple Apollo Compiler plugins ([#6523](https://github.com/apollographql/apollo-kotlin/pull/6523))
38+
39+
**Runtime**:
40+
41+
* [new] Add cacheInterceptor() and autoPersistedQueriesInterceptor() ([#6455](https://github.com/apollographql/apollo-kotlin/pull/6455))
42+
* [new] Add `ApolloCall.ignoreUnknownKeys` and `ApolloClient.Builder.ignoreUnknownKeys` ([#6473](https://github.com/apollographql/apollo-kotlin/pull/6473))
43+
* [fix] fix the batch size not respected issue ([#6528](https://github.com/apollographql/apollo-kotlin/pull/6528))
44+
* [fix] Fix losing response headers when using batch request ([#6538](https://github.com/apollographql/apollo-kotlin/pull/6538))
45+
46+
**AST**:
47+
* [new] Add allowAddingDirectivesToExistingFieldDefinitions ([#6470](https://github.com/apollographql/apollo-kotlin/pull/6470))
48+
* [new] Implement schema coordinates ([#6560](https://github.com/apollographql/apollo-kotlin/pull/6560))
49+
50+
**Execution**
51+
* [fix] Implement defaultValues coercion ([#6440](https://github.com/apollographql/apollo-kotlin/pull/6440))
52+
* [new] Add `JsonCoercing` ([#6471](https://github.com/apollographql/apollo-kotlin/pull/6471))
553

654
# Version 4.3.1
755

@@ -828,10 +876,10 @@ release (#5449) and is now fixed.
828876

829877
* [compiler] validate operation directives & enforce presence of the nullability directive definitions by @martinbonnin
830878
in https://github.com/apollographql/apollo-kotlin/pull/5443
831-
* [build] Bump okio version by @martinbonnin in https://github.com/apollographql/apollo-kotlin/pull/5447
832-
* [build] Bump uuid version by @martinbonnin in https://github.com/apollographql/apollo-kotlin/pull/5448
833-
* Fix 2nd step introspection by @BoD in https://github.com/apollographql/apollo-kotlin/pull/5451
834-
* Add wasmJs target by @martinbonnin in https://github.com/apollographql/apollo-kotlin/pull/5458
879+
* [build] Bump okio version https://github.com/apollographql/apollo-kotlin/pull/5447
880+
* [build] Bump uuid version https://github.com/apollographql/apollo-kotlin/pull/5448
881+
* Fix 2nd step introspection https://github.com/apollographql/apollo-kotlin/pull/5451
882+
* Add wasmJs target https://github.com/apollographql/apollo-kotlin/pull/5458
835883
* Add validation to check schema definitions are compatible with the bundled ones by @BoD
836884
in https://github.com/apollographql/apollo-kotlin/pull/5444
837885

docs/source/migration/5.0.mdx

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,82 @@ subtitle: Step-by-step guide on migrating from Apollo Kotlin 4
44
description: Learn how to migrate from version 4 with key changes, new features, and tools designed for improved stability and maintainability. Follow step-by-step guidance and make a seamless transition
55
---
66

7-
⚠️ This is a work in progress ⚠️
7+
Apollo Kotlin 5 is mostly binary compatible with Apollo Kotlin 4 with a few exceptions:
88

9-
Behaviour changes:
9+
- Symbols that were `DeprecationLevel.ERROR` in v4 are now removed.
10+
- `apollo-compiler` has breaking changes and is generally still considered unstable with the exception of persisted queries compiler plugins:
11+
- `ApolloCompilerPlugin.beforeCompilationStep()`, `ApolloCompilerRegistry.registerOperationIdsGenerator()` and dependent symbols are stable and will go through the usual deprecation cycle if they ever need to change.
12+
- The APIs used by the data builders generated sources (`buildData`, `ObjectBuilder`, `CustomScalarAdapters.PASSTHROUGH`...) have changed. This is not an issue unless you called those APIs directly or distributed data builders code in a library. In that last case, your consumers will have to update to Apollo Kotlin 5.
13+
- A few symbols were not supposed to be exposed and have been removed:
14+
- `BooleanExpression.simplify()`
15+
- `DefaultHttpRequestComposer.HEADER_APOLLO_OPERATION_ID`
16+
- ...
1017

11-
* [ ] https://github.com/apollographql/apollo-kotlin/pull/6455
12-
* [ ] https://github.com/apollographql/apollo-kotlin/pull/6485
18+
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.
1319

14-
Removed APIs
20+
## Removed `Service.operationOutputGenerator` and `Service.operationIdGenerator`
1521

16-
* [ ] https://github.com/apollographql/apollo-kotlin/pull/6494
17-
* [ ] https://github.com/apollographql/apollo-kotlin/pull/6492
18-
* [ ] #6496
22+
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.
23+
24+
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.
25+
26+
Apollo Kotlin v5 instead runs its compiler in isolated classloaders, meaning generating the ids now needs to happen in that same classloader.
27+
28+
To do so, use `ApolloCompilerPlugin`:
29+
30+
```kotlin
31+
class MyPlugin : ApolloCompilerPlugin {
32+
override fun beforeCompilationStep(
33+
environment: ApolloCompilerPluginEnvironment,
34+
registry: ApolloCompilerRegistry,
35+
) {
36+
registry.registerOperationIdsGenerator {
37+
it.map { OperationId(it.source.md5(), it.name) }
38+
}
39+
}
40+
}
41+
```
42+
43+
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.
44+
45+
46+
47+
## Removed ApolloIdlingResource
48+
49+
Apollo Kotlin 5 removes `ApolloIdlingResource`. `IdlingResource` usage has been slowly decreasing and there are now better alternatives to do your testing.
50+
51+
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).
52+
53+
## Using `@nonnull` is now an error
54+
55+
Apollo Kotlin 4 had a `@nonnull` client directive to force generating fields as non-null.
56+
57+
Since `@nonnull`, we've worked hard with the [nullability working group](https://github.com/graphql/nullability-wg/) to improve the handling of null types in GraphQL.
58+
59+
As part of this effort, it was recognized that the nullability information belongs to the schema. Fields that are only nullable for error reasons can now be marked with `@semanticNonNull`:
60+
61+
```graphql
62+
type User {
63+
email: String @semanticNonNull
64+
}
65+
66+
# or if you don't own the schema, use extensions
67+
extend type User @semanticNonNullField(name: String)
68+
```
69+
70+
The client can then decide how to handle errors with `@catch`:
71+
72+
```graphql
73+
query GetUser {
74+
user {
75+
# generated as `String?` (current default)
76+
email @catch(to: NULL)
77+
# generated as `Result<String, Error>`
78+
email @catch(to: RESULT)
79+
# generated as `String`, throws if there is an error
80+
email @catch(to: NULL)
81+
}
82+
}
83+
```
84+
85+
You can read more in the ["handling nullability" page](https://www.apollographql.com/docs/kotlin/advanced/nullability).

0 commit comments

Comments
 (0)