apollo-kotlin

 A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.

MIT License

Stars
3.7K
Committers
247

Bot releases are visible (Hide)

apollo-kotlin -

Published by martinbonnin almost 4 years ago

Version 2.4.5 is a minor release with Gradle plugin improvements for manipulating schemas as well as a few other bugfixes.

convertApolloSchema

You can now convert your schema from Json to SDL and vice-versa:

./gradlew convertApolloSchema --from schema.json --to schema.sdl

pushApolloSchema

You can now push a schema to your Apollo Studio registry:

./gradlew uploadApolloSchema --key $key --graph $graph --schema schema.sdl

Full Changelog

✨ New

[Gradle Plugin] add ./gradlew convertApolloSchema --from schema.json --to schema.sdl (#2757)
[Gradle plugin] Add pushApolloSchema (#2737)
[Publishing] add version and a few other attributes to the jar Manifest (#2736)
[Runtime] Introduce custom error class for better error handling (#2751)

👷‍ Fixes

[Codegen] Fix capitalized field names in input objects (#2746)

apollo-kotlin -

Published by martinbonnin almost 4 years ago

Version 2.4.4 is a hotfix release to disable using Kotlin parameters default values to represent GraphQL variables default values (#2741). This is not needed as the server can infer the variable default value from the query document and created a bunch of other issues (#2744 and #2742) in addition to sending uneeded variables alongside the query.

query GetHero($myBool: Boolean = true) { ... }

will now correctly generate

// no variable will be sent alongside the query by default
// and the server will read the default value from the GraphQL query document
data class GetHero(val myBool: Input<Boolean> = Input.absent())

This bug was introduced in version 2.4.2. If you're using GraphQL queries with variables default values, please upgrade to 2.4.4.

#2741 also fixes a crash in the handling of @include directives using variables default values in a much less invasive way. Many thanks to @DSteve595 for investigating this and pointing to the correct solution.

Changes:

  • [Codegen] Revert default values as Kotlin default parameters and made skipField more robust (#2741)
apollo-kotlin -

Published by martinbonnin almost 4 years ago

Version 2.4.3 is a minor version to fix a regression in ./gradlew downloadApolloSchema introduced in 2.4.2. The task would fail asking for a service even if schema and endpoint were correctly passed (See #2728 for more details).
Many thanks to @nicusorflorin for spotting this!

Other included fixes:

[SDL] better handling of string escapes (#2729)
[KMP] added a 'timeoutMillis' parameter to ApolloHttpNetworkTransport (#2680)

apollo-kotlin -

Published by martinbonnin almost 4 years ago

Version 2.4.2 is a maintenance release with language improvements and fixes, better SQL cache debug, Websocket management and more.

SDL type extensions

Type extensions are now supported in SDL schemas. SDL schema can now include extension like below:

extend type Starship {
  shieldLevel: Float!
}

Variable default values

Apollo Android now supports default values for variables (#2704)

query GetHero(
  $myBool: Boolean = true,
  $unit: LengthUnit! = FOOT,
  $listOfInts: [Int] = [1, 2, 3]
) {
  ...
}

will generate:

data class GetHero(
  val myBool: Input<Boolean> = Input.optional(true),
  val unit: LengthUnit = LengthUnit.safeValueOf("FOOT"),
  val listOfInts: Input<List<Int?>> = Input.optional(listOf(1, 2, 3))
) 

This only works for scalar types and their list/nonnull declinations. Full support for input object will be added later. Follow #2572 for updates

Better subscription Websocket management

SubscriptionManger.reconnect is now exposed as public API. It can be called to reconnect a WebSocket if credentials/token needs to be refreshed.

Full Changelog

✨ New

[Subscriptions] expose SubscriptionManager.reconnect() (#2706)
[Compiler] Add support for default variable values (#2704)
[SQL cache] implement SqlNormalizedCache.dump (#2709)
[SDL] add support for type extensions (#2666)
[Multi-modules] Add packageName option to override fragments package name (#2669)

👷‍ Fixes

[Compiler] fix @deprecated(reason:"") directive (#2720)
[Compiler] fix @deprecated directive without any deprecation reason (#2692)
[Gradle plugin] fix downloadApolloSchema variants detection (#2712)
[Compiler] support multiple arguments in directives (#2711)
[Compiler] Fix merging fields would forget inline fragments in some cases (#2689)
[Multiplatform] set the correct Content-Type on iOS (#2691)
[SDL] allow to have schemas without mutations/subscriptions (#2684)
[Gradle Plugin] Make CheckDuplicate task cacheable (#2688)
[Java codegen] Do not try to annotate primitive types in List type parameters (#2663)
[Compiler] Fix Missing Referenced Fragments in Root query type (#2647)
[Publishing] fix the license url and a few other dangling urls after the master -> (#2639)

📖 Documentation

[Documentation] use the correct "image/jpeg" mimetype. (#2699)

❤️ External contributors

Many thanks to:

  • @tylerbwong for diving deep into root query types fragments and inline fragments
  • @olivierg13 for making the Gradle build cache always better
  • @Laimiux for making multi-module package names more sensible
  • @renclav, @MadJonTurck, @DSteve595, @benoitletondor and @NitroG42 for all the detailed feedback and investigations, this helps a ton !
apollo-kotlin -

Published by martinbonnin about 4 years ago

Version 2.4.1 brings a bunch of bug fixes, support for Gradle configuration cache and better Apollo Studio integration.

Gradle configuration cache

Apollo Android now supports Gradle configuration cache. Configuration cache is still an incubating Gradle feature. If you notice any warning in your builds, please file an issue

Studio integration

Users of Apollo Studio can now use the built-in ApolloClientAwarenessInterceptor to get more insights about their Android clients. Check the related documentation for more details how to do this.

Also, the Gradle plugin can now download schemas from the registry in addition to using introspection. To download a schema from the registry, use the --graph argument:

./gradlew downloadApolloSchema --graph $APOLLO_GRAPH --key $APOLLO_KEY --schema schema.[json | sdl]

Full Changelog

✨ New

[Gradle Plugin] add registry download (#2617)
[Runtime] add a client awareness OkHttp interceptor (#2603)
[Gradle Plugin] configuration cache compatibility (#2608)

👷‍ Fixes

[Compiler] fix line wrapping on long lines with forEach lambda. (#2621)
[Compiler] fix cache key for arguments that contain lists (#2592)
[Gradle Plugin] fix absolute paths in windows (#2615)

⚙️ Internal

[Runtime] Fix some operation log calls (#2599)

❤️ External contributors

Many thanks to @SamuelFrankSmith, @BenSchwab, @moshkit, @annieechen for their awesome work on codegen, runtime, documentation and help keep the project in good shape in general!

apollo-kotlin -

Published by martinbonnin about 4 years ago

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 calling refetch() 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 of master (#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!

apollo-kotlin -

Published by martinbonnin about 4 years ago

Kotlin 1.4 release

This is the Kotlin 1.4 release. It contains native binaries compiled for 1.4 and bumps some dependencies.

It also fixes ApolloCall.Builder.useHttpGetMethodForQueries, thanks a lot to @ubuntudroid for diving into this!

✨ New

  • Kotlin 1.4 support (#2510)

👷‍♂️ Fixes

  • Fix RealApolloCall.toBuilder() not respecting useHttpGetMethodForQueries (#2530)
apollo-kotlin -

Published by martinbonnin about 4 years ago

⚠️ Auto Persisted Queries changes

Enabling Auto Persisted Queries with ApolloClient.Builder.enableAutoPersistedQueries(true) will now enable mutations as well (#2509). This should cause no problem in the vast majority of cases. Server supporting auto persisted queries usually support auto persisted mutations as well. As a precautionary measure, we nonetheles recommend testing the integration with your server after upgrading.

JS support for generated models

The generated models and parsers can now target Javascript thanks to @andersio and @omainegra 💛. Check out the documentation for adding it to your multiplatform project. For runtime support, follow this issue.

OperationOutputGenerator

In addition to OperationIdGenerator, you can now generate operation IDs in batch. This is useful if your backend requires a list of operations to whitelist that should be sent all at once.

Exemple usage:

// build.gradle.kts
apollo {
    // ...
    operationOutputGenerator.set(object : com.apollographql.apollo.compiler.OperationOutputGenerator {
        // don't forget to bump the version if you change the implementation
        override val version = "v1"

        override fun generate(operationDescriptorList: Collection<OperationDescriptor>): OperationOutput {
            return operationDescriptorList.associate {
                it.source.md5() to it
            }
        }
    })
}

Full Changelog

✨ New

  • [Gradle Plugin] add a way to generate operation ids as batch (#2476)
  • [Multiplatform] JS support in apollo-api (#2467)
  • [SDL] add a basic validation test (#2493)

👷‍♂️ Fixes

  • [Runtime] AutoPersistedQueries supported for mutations
  • [Runtime] add missing @Deprecated and toBuilder for ApolloMutationCall (#2501)
  • [Kotlin Runtime] do not use Java8 forEach which is not available on some older android versions (#2517)
  • [SqlLite Cache] bump SqlDelight version, fixes compatibility with SqlDelight 1.4.0 (#2508)
  • [Plugin] better error message for multiple schemas (#2488)
  • [Compiler] allow defaultValue="null" for non-string scalar types (#2490)
  • [RxJava2] Add is disposed checking to single (#2480)
  • [SQL Cache] Fix writeToCacheAsynchronously boolean always false when prepareInterceptorChain() is called (#2484)

⚡ Performance

⚙️ Internal

  • [apollo-api] prefix Boolean Kotlin properties with is for better java interop (#2474)

❤️ External contributors

Many thanks to @JakeSteam, @nymerias, @s1ee, @andersio, @omainegra and @olivierg13 for their awesome contributions!

apollo-kotlin -

Published by martinbonnin about 4 years ago

Highlights

Normalized cache performance improvements:

Continuing from version 2.2.2, this version adds even more cache performance improvements. For SqlNormalizedCache, reads are now wrapped in a transaction, which will make things faster, especially on large objects (#2422).
You also have the option to opt-in asynchonous cache writes (#2416):

apolloClient.normalizedCache(cacheFactory, cacheKeyResolver, true)

Passing true for writeToCacheAsynchronously will make your UI display faster since it will get the network response without waiting for the cache write to happen.

SDL schema support:

Apollo Android now supports SDL (Schema Definition Language) for schemas (#2417). SDL is more concise and easier to read than the introspection json. To use it, place your SDL file in src/main/graphql/$some/$subdirectory/schema.sdl

✨ New

  • [Codegen] Enable SDL schema Apollo Plugin support (#2417)
  • [Performance] Batch normalized sql cache reads (#2422)
  • [Performance] Run ApolloCacheInterceptor store write on dispatcher thread (#2416)
  • [Runtime] add ApolloClient.autoPersistedOperationsInterceptorFactory (#2420)
  • [apollo-normalized-cache] multiplatform support (#2457)

👷‍♂️ Fixes

  • [Publication] Fix packaging of apollo-normalized-cache (#2465)
  • [Compiler] Fix issue with using inline fragment inside another inline fragment (#2462)
  • [LruNormalizedCache] Fix a most likely Java -> Kotlin conversion error in the weighteer implementation (#2428)
  • [Kotlin Runtime] calling cancel() on the connection closes it too early, keep the (#2426)
  • [Build] unbreak the generation of com.apollo.compiler.VERSION (#2424)
  • [Subscriptions] Allow calls to WebSocketSubscriptionTransport#send when not connected. (#2419)
  • [Compiler] Support empty graphql files (#2418)
  • [Coroutines-support] expose runtime/coroutines dependencies (#2415)

⚙️ Internal

  • [Runtime] deprecate the "builder" methods on ApolloCall and add them on the Builder instead (#2434)
  • [Build scripts] make the project compile with jdk13 (#2449)
  • [Tooling] 🛠️ Add tasks to check if the API is backward compatible (#2408)
  • [Compiler] Refactor package structure for GraphQL and SDL parsers (#2411)

❤️ External contributors

Many thanks to @BenSchwab, @jeffnyauke, @DSteve595, @Shevatro and @baconz for their awesome contributions!

apollo-kotlin -

Published by martinbonnin over 4 years ago

Important

This release fixes an important performance issue with the multiplatform sql-normalized-cache-sqlite introduced in version 2.0.0. If you are using it, updating is strongly recommended. See #2412 for more details.

✨New

  • [Kotlin Runtime] subscriptions (#2356 and #2388)
  • [Plugin] ./gradlew downloadApolloSchema now resolves the schema path automatically if not specified (#2380)

👷‍♂️Fixes

  • [Normalized Cache] Run SqlNormalizedCache merge in transaction (#2412)
  • [Kotlin Runtime] make coroutines and OkHttp API dependencies (#2384)
  • [Compiler] fix marshaller is nullable (#2404)
  • [Plugin] check versions lazily (#2400)

⚙️ Internal

  • [Publishing] add ./gradlew publishToOssStagingIfNeeded (#2385)
  • [Compiler] work in progress on SDL support (#2398 and #2406)
apollo-kotlin -

Published by martinbonnin over 4 years ago

Summary

This version is a maintainance release to add the STORE_PARTIAL_RESPONSES cache header. Version 2.1.0 changed the caching behaviour to not store partial response if there are errors. This is the expected behaviour in the large majority of cases but some use cases might rely on this old behaviour. If you are in this case, you can now opt-in the previous behaviour with STORE_PARTIAL_RESPONSES. See #2363 for more details.

New

  • [Cache] Add opt-in to cache responses with errors (#2363)

Bugfixes

  • [Multiplatform] do not escape the variables json (#2377)
  • [Compiler] Don't merge inline fragment with directives (conditions) (#2352)
  • [Subscriptions] make the error message if subscriptions are not configured more actionable (#2373)

Misc

  • The documentation now contains a tutorial and different "getting started" pages for Jav/Kotlin/Multiplatform
  • The artifacts hosted on JCenter are now signed with an apollographql GPG key (key ID 5A446C80C27E095353CF3969F165A96372E61948) instead of the default Bintray key before.
apollo-kotlin -

Published by martinbonnin over 4 years ago

Summary

This version, amongst other things, contains RxJava3 support, a new way to register ApolloInterceptor with factories and makes it easier to download your schema.json from the command line. Starting with this version, releases are published on Maven Central in addition to Jcenter.

RxJava3 support (#2304)

Version 2.2.0 includes support for RxJava3. To use it, add the dependency to your Gradle file:

// RxJava3 support
implementation("com.apollographql.apollo:apollo-rx3-support:x.y.z")

The dependency contains static and extension methods to convert ApolloCall, ApolloSubscriptionCall, etc... to their RxJava3 counterparts.

For an exemple, to convert an ApolloCall to an Observable:

Java:

// Create a query object
EpisodeHeroName query = EpisodeHeroName.builder().episode(Episode.EMPIRE).build();

// Create an ApolloCall object
ApolloCall<EpisodeHeroName.Data> apolloCall = apolloClient.query(query);

// RxJava3 Observable
Observable<Response<EpisodeHeroName.Data>> observable3 = Rx3Apollo.from(apolloCall);

Kotlin:

// Create a query object
val query = EpisodeHeroNameQuery(episode = Episode.EMPIRE.toInput())

// Directly create Observable with Kotlin extension
val observable = apolloClient.rxQuery(query)

You can read more in the dedicated section of the documentation.

ApolloClient.applicationInterceptorFactories() (#2302)

ApolloInterceptors added with ApolloClient.applicationInterceptor() were only created once for the lifetime of the ApolloClient so the same interceptor was always disposed. If you need your interceptor to start with a new state for each call, you can use ApolloInterceptorFactory that will create a new interceptor for each new call.

Simplified downloadApolloSchema task usage from the command line (#2321)

Using the downloadApolloSchema task from the command line is now easier:

# Instead of using properties:
./gradlew downloadApolloSchema -Pcom.apollographql.apollo.endpoint=https://your.graphql.endpoint \
-Pcom.apollographql.apollo.schema=src/main/graphql/com/example/schema.json

# You can now use `--endpoint` and `--schema`:
./gradlew downloadApolloSchema --endpoint=https://your.graphql.endpoint --schema=app/src/main/graphql/com/example/schema.json

Fixes

  • Change constructor visibility for WebSocketSubscribtionTransport (#2348)
  • [Runtime] fix AbstractMethodError due to @JvmSynthetic (#2349)
  • Fix issue with query root level fragment support. (#2344)
  • Add check for missing selection set for object types. (#2344)
  • [Subscriptions] make a copy of the list to avoid ConcurrentModificationException (#2332)
  • [Gradle Plugin] Use relative strings for the rootFolder input property so as not to break cacheability (#2294)
  • [Build] release artifacts on maven central (#1130)

Internal changes

  • Provide base websocket abstraction (#2311)
  • [Kotlin Runtime] Add BearerTokenInterceptor (#2298)
  • [Tooling] enable checkstyle again (#2296)
  • Fix a small issue in sample (#2308)
apollo-kotlin - v2.1.0

Published by martinbonnin over 4 years ago

Important changes

The normalized cache will not store partial response data anymore if the response contains errors (#2281). This is to avoid storing inconsistent data. Make sure that your code doesn't rely on this behaviour before upgrading.

New features

  • It is now possible to generate GraphQL enum types as sealed classes to retain their rawValue. (#2279)

For this, use the sealedClassesForEnumsMatching gradle option:

// build.gradle.kts
apollo {
    sealedClassesForEnumsMatching.set(listOf("SomeEnum", "OtherEnum"))
}

Fixes

  • [Runtime] ApolloStore.write fragment crash on execute (#2289)
  • [Plugin] Create the directory for the user if needed during the schemaDownload (#2283)
  • [Cache] Prevent incorrect caching of partial responses with errors (#2281)
  • [Runtime] Revert okhttp to 3.12 to continue supporting Android 4.4 (#2269)
  • [Codegen] Improve performance of the codegen (#2257)
  • [Plugin] Also take into account the root project when enforcing versions (#2254)

Internal changes

  • [Tooling] enable checkstyle again (#2296)
  • [Documentation] Reorganize docset (#2292)
  • [Runtime] Fix wrong error message in CallState (#2290)
  • [Codegen] Update codegen tests (#2260)
  • [Multiplatform] Make Execution context more Kotlin coroutine context idiomatic (#2258)
  • [Multiplatform] Kotlin runtime initial structure (#2256)
  • [Multiplatform] Introduce GraphQL execution context (#2248)
apollo-kotlin - v2.0.3

Published by martinbonnin over 4 years ago

Technical release to revert multiplatform apollo-normalized-cache-sqlite until we figure out how to handle https://github.com/apollographql/apollo-android/issues/2253

apollo-kotlin - v2.0.2

Published by martinbonnin over 4 years ago

Important Fixes

Since version 2.0.0, the normalized cache could behave unpredictably when trying to update a CacheKey:

  • Fix issue with sql cache not updated for the same CacheKey (#2245)

Internal changes

  • Fix issues with Kotlin Multiplatform setup (#2238)
  • Make sqlite module multiplatform Component: Kotlin MPP (#2234)
  • Migrate Transaction and EvictionPolicy to Kotlin (#2144)

New features

There's now a shiny Swift UI demo app using Kotlin multiplatform models:

  • Swift UI funtimes for iOS Sample App on KMP (#2223)
  • Generate synthetic accessor for optional list properties (#2232)

80329982-8bd07880-8809-11ea-8ad6-48e5b55f6f4c

apollo-kotlin - v2.0.1

Published by martinbonnin over 4 years ago

New features

You can now add comments to your .graphql queries.

For an example:

# This is a sample query to fetch hero name
# that demonstrates Java / Kotlin docs generations
# for query data model
query TestQuery {
 ...
}

Will produce somthing like:

/**
 *  This is a sample query to fetch hero name
 *  that demonstrates Java / Kotlin docs generations
 *  for query data model
 */
@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName",
    "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter")
class TestQuery : Query<TestQuery.Data, TestQuery.Data, Operation.Variables> {

Bug Fixes

  • Make sure generated code do not produce warnings (#2219)
  • Migrate Transaction and EvictionPolicy to Kotlin (#2144)
  • Fix eager asFlow() completion (#2214)
  • Take nullity into account to generate correct code (#2213)
  • Add missing Java/Kotlin Docs generation for generated classes (#2210)

Internal Changes

  • Convert ApolloStore to kotlin (#2144)
  • Update OkHttp for important fixes (#2215)
apollo-kotlin - v2.0.0

Published by tasomaniac over 4 years ago

Important Changes

Kotlin Multiplatform

We are really excited to announce that with this release it is possible to build Kotlin Multiplatform apps with Apollo. The supported targets are Android / iOS / JVM. Currently only apollo-api module supports Kotlin Multiplatform. It is enough to use the generated code for preparing request body for Http calls and parse the response body.

This is a backward compatible change for existing users. Please keep in mind that it will bring Kotlin standard library as a transitive dependency.

Side effect changes of Kotlin migration:

  • Some primitive types like Booleans may be unboxed where appropriate
  • Classes and functions are final unless they are intentionally marked as open
  • Kotlin-stdlib is added as a transitive dependency
  • Jvm target version is now 1.8
  • Gradle 6.x recommended. In 5.x, Gradle Metadata needs to be enabled by putting this into settings.gradle enableFeaturePreview("GRADLE_METADATA")

Okio and OkHttp migration

During Kotlin Multiplatform integration, Okio and OkHttp are migrated to their latest major versions to make use of their Kotlin support.
Okio is upgraded to 2.4.3 and OkHttp is upgraded to 4.4.0

Note: If you explicitly depend on these libraries, it would be recommended to do major version upgrade of this libraries first before upgrading Apollo.

Both of them are binary compatible for Java users. There are some source incompatible changes for Kotlin users. Please use Code Cleanup feature of IntelliJ / Android Studio to automatically handle the migration. More info can be found here: https://square.github.io/okhttp/upgrading_to_okhttp_4/

Update Okio and Okhttp (#2054)

New Normalized Cache Modules

For in-memory LruNormalizedCache users, no change required since apollo-runtime brings it as transitive dependency. It is still recommended adding the following dependency explicitly: implementation("com.apollographql.apollo:apollo-normalized-cache:x.y.z")

Apollo normalized cache module (#2142)

SqlNormalizedCache is moved to its own module. If you added apollo-android-support for disk cache, replace it with new dependency.

// Replace:
implementation("com.apollographql.apollo:apollo-android-support:x.y.z")

// With:
implementation("com.apollographql.apollo:apollo-normalized-cache-sqlite:2.0.0")

ApolloSqlHelper is deprecated. Instantiate SqlNormalizedCacheFactory class with same arguments instead.

// Replace:
val apolloSqlHelper = ApolloSqlHelper.create(context, "db_name")
val cacheFactory = SqlNormalizedCacheFactory(apolloSqlHelper)

// With:
val cacheFactory = SqlNormalizedCacheFactory(context, name = "db_name")

Replace legacy Android SQL with SqlDelight (#2158)

Deprecated Gradle Plugin is removed

The deprecated Gradle Plugin is now removed. Please refer to migration guide from previous releases before upgrading to 2.0
https://www.apollographql.com/docs/android/essentials/migration/#gradle-plugin-changes

Bug-fixes

  • Suppress raw type warning in generated code (#2149)
  • Fix issue with long query name generates bad formatted kotlin code (#2153)
  • Fix an issue where removing graphql files does not remove the generated files (#2170)
  • Fix asFlow() leak (#2175)
  • Put special KotlinPoet character to avoid broken wrapped code (#2190)

Kotlin Multiplatform Support

  • Migrate Http cache api module to kotlin (#2051)
  • Migrate Utils to kotlin (#2052)
  • Refactor ScalarType (#2063)
  • Add iOS targets to API module (#2070)
  • fix KMP artifacts (#2084)
  • Convert top level api classes to Kotlin (#2021)
  • Convert bunch of internal classes to Kotlin (#2028)
  • Convert generic reader / writer Json classes to Kotlin (#2042)
  • Convert OperationDataJsonSerializer to Kotlin by keeping existing Java api compatible. (#2050)
  • Migrate logger to Kotlin (#2047)
  • Convert next portion of api module files to Kotlin (#2044)
  • Remove redundant supplier class and use Kotlin Function0 (#2059)
  • Introduce Kotlin Multiplatform into apollo-api module (#2062)
  • Fix publish task to cover Kotlin MPP (#2067)
  • Some Kotlin MPP publication fixes (#2072)
  • [Gradle Plugin] Support Kotlin multiplatform (#2120)
  • Kotlin Multiplatform Sample (#2136)
  • More Kotlin in normalized-cache (#2151)
  • Migrate some normalized cache classes (#2148)
  • Generate 'composeRequestBody' to encode GraphQL POST request payload (#2150)
  • Add overloaded constructors for SqlNormalizedCacheFactory (#2189)
  • Fix some of the dependency issues (#2168)
  • Enable support for generics Objective-C interop (#2174)
  • KMP sample: coroutines in common code (#2160)
  • Generate overloaded parse method for ByteString (#2178)
  • Fix compat issues on iOS target (#2177)
  • Replace DetachedObjectGraph wrapper with stable ref. (#2198)

Clean up / Maintenance

  • Remove apollo-gradle-plugin-deprecated (#2015)
  • Fix deeplink to plugin config (#2056)
  • bump gradle version to 6.2.2 (#2085)
  • Update agp to 3.6 (#2088)
  • Move to GitHub actions (#2091)
  • Avoid doc duplication by using README.md on gatsby as well (#2053)
  • Expose per repo publishing tasks (#2094)
  • update Releasing.md (#2101)
  • Updated Coroutines documentation with new extensions, removed depreciated extensions. (#2105)
  • Silence sdkmanager (#2113)
  • Move migration guide (#2114)
  • Move getting started to top level (#2118)
  • Add contribution instructions to README (#2110)
  • Skip CI checks if the changes are only for documentations (#2115)
  • fix tag detection (#2123)
  • Move test class back into test sources (#2147)
  • Add full exceptions for better error output on CI (#2155)
  • Update docs for 2.0.0 release (#2169)
  • Remove some deprecated declarations and usages for 2.0 (#2161)
  • Update maven publishing (#2172)
  • bump the plugin-publish version. (#2195)
  • Make kotlin-sample project use generated Kotlin models (#2196

External Contributions

Thanks @ralphie9224 @zachburt05 @odlund @zhuhaow @lwasyl @SubhrajyotiSen for contributions

apollo-kotlin - v1.4.5

Published by tasomaniac over 4 years ago

Bug Fixes

  • Suppress raw type warning in generated code (#2149)
  • Fix issue with long query name generates bad formatted kotlin code (#2153)
  • Fix an issue where removing graphql files does not remove the generated files (#2170)
  • Fix asFlow() leak (#2175)
  • Put special KotlinPoet character to avoid broken wrapped code (#2190)
apollo-kotlin - v1.4.4

Published by tasomaniac over 4 years ago

Bug Fixes

  • Fix issue with fragment field type conditions (#2125)
  • Generate Mapper function for Kotlin models (#2130)
apollo-kotlin - v1.4.3

Published by tasomaniac over 4 years ago

Bug Fixes

  • Fix query watcher not calling status events (#2102)
  • Fix duplicate class generation in test folders (#2106)
  • Fix issue with HttpCache causes HttpParseException (#2107)
  • Fix IdlingResources issue with Watcher (#2108)
  • Scope fields in operation variables (#2122)