Version 2.4.0 brings multiple new features and bugfixes. Read below for the most important changes and full changelog
Experimental Multi-Modules support
Version 2.4.0 brings Multi-Modules support. With Multi-Modules, you can reuse GraphQL fragments from different Gradle modules for better separation of concerns and improved build speed.
Configure your parent module to generate Apollo metadata:
// parent/build.gradle.kts
apollo {
generateApolloMetadata.set(true)
}
And declare your parent module as a dependency of your feature module:
// feature/build.gradle.kts
dependencies {
implementation("com.apollographql.apollo:apollo-runtime:xyz")
// more regular dependencies
// Apollo dependencies
apolloMetadata(project(":parent"))
// You still need to declare the parent module as a regular dependency
implementation(project(":parent"))
}
For more information, read the official documentation
⚠️ Multi-Modules is currently experimental and we'd love to hear how it worked (or not worked) for you. We welcome issues/feedback through the Github Issues
SDL schemas improvements
Version 2.4.0 brings even more fixes and tools to work with SDL schemas. SDL schemas are a more concise and readable way to work with GraphQL schemas. To use them, replace schema.json
with your SDL schema schema.sdl
. You can get a SDL schema from your GraphQL Playground if your endpoint has an associated Playground instance. If you don't have a playground instance or another way to download a SDL file, version 2.4.0 can make an introspection query and save it in SDL format. The schema will be saves as Json or SDL depending on the filename extension:
./gradlew downloadApolloSchema --endpoint https://your.graphql/endpoint --schema src/main/graphql/com/example/schema.sdl
Coroutines
If you're using apollo-coroutines-support
, version 2.4.0 brings apolloCall.await()
(#2574). It is more concise than the previous apolloCall.toDeferred().await()
and also respects structured concurrency. We strongely encourage to move to .await()
. Many thanks to @R4md4c for adding this!
Kotlin 1.4.10
The Kotlin 1.4.10 ecosystem is moving forward and we bumped a few dependencies (sqldeligh, okio, kotlin-compile-testing, coroutines and obviously kotlin).
The Gradle plugin is also compiled against Kotlin 1.4.10 despite Gradle forcing Kotlin 1.3.72 at runtime. We compile with apiVersion = "1.3"
and our tests do not show any issue but please let us know if you see any weird Gradle behaviour.
FileUpload
Version 2.4.0 fixes how files were written in variables (#2566) and allows to subclass FileUpload
to make it work without a File
. With Android 11 and scoped storage out of the door, this will allow to upload from a content uri or any other data source. The API was inspired by OkHttp RequestBody
. If you ever used OkHttp before, you shouldn't be disoriented:
object upload : FileUpload(mimetype) {
override fun contentLength(): Long {
TODO("return contentLength here")
}
override fun fileName(): String? {
TODO("return fileName to use in the multipart request here")
}
override fun writeTo(sink: BufferedSink) {
TODO("write the data here")
}
}
Full Changelog
✨ New
- Multi-module support (#2514)
- [Plugin] Allow to download SDL schemas (#2586)
- [Plugin] Add an option to fail on deprecated usages (#2575)
- [FileUpload] allow to sub class FileUpload (#2569)
- [FileUpload] Allow to encode custom scalar types as null and use it for file uploads (#2566)
- [Coroutines] Add
ApolloCall.await
with better structured concurrency support. (#2574)
👷♂️ Fixes
- [RxJava] fix
retry()
(#2587) Note that this is a behaviour change and this will clone the operation under the hood. If you were callingrefetch()
directly, you might need to update your calling code. - [SDL] Fix a scalar definition after a union defintion (#2559)
- [Compiler] fix optional Int properties with an uppercase name (#2543)
- [SQLNormalizedCache] fix watcher not called on initial cache write (#2538)
⚙️ Internal
- Update CI to use
main
instead ofmaster
(#2594) - Update LICENSE with new organization name (#2584)
- Add Kotlin as language for the codeblock (#2580)
- Bump Kotlin to 1.4.10 (#2578)
- Bump sql delight version to 1.4.3 (#2564)
- Compile Kotlin against stdlib 1.3 (#2555)
- Put the location of the .xcodeproj file for Kotlin Multiplatform Mobile integration in Android Studio (#2554)
- [Plugin] allow running the plugin on Gradle 5.6 (#2539)
- Bump kotlin compile testing (#2547)
❤️ External contributors
Many thanks to @R4md4c, @dush1729, @jaggs6 for their awesome work on coroutines, documentation and keeping the project in good shape in general!