releases.shpreview
Apollo GraphQL/Apollo Kotlin

Apollo Kotlin

$npx -y @buildinternet/releases show apollo-kotlin
Mon
Wed
Fri
AprMayJunJulAugSepOctNovDecJanFebMarApr
Less
More
Releases8Avg2/moVersionsv4.4.0 → v5.0.0-alpha.7
Oct 1, 2024

This release contains a handful of bug fixes and improvements.

⚙️ Add ApolloCompilerPlugin.schemaListener()

The compiler plugins API has been extended to allow listening to schema changes.
This can be used to have plugins generate code based on the schema. To do this, implement the schemaListener function on your plugin:

class MyCompilerPlugin() : ApolloCompilerPlugin {
  @ApolloExperimental
  override fun schemaListener(): SchemaListener {
    return object : SchemaListener {
      override fun onSchema(schema: Schema, outputDirectory: File) {
        // Generate some code inside outputDirectory based on schema
      }
    }
  }
}

🚀 Allow mapping scalars to simple generic types

Previously, to map a scalar to a generic type, you had to use a typealias. Now, simple generic types are accepted, and common types like List and String don't need to be fully qualified:

mapScalar("MassList", "List<com.example.Measure<com.example.Mass>>", "com.example.MassListAdapter")

💙 Contributors

Many thanks to @ebrattli, @agrosner and @cvb941 for their contributions to this release 💙!

👷 All changes

  • [gradle-plugin] Deprecate "operationOutput" and ./gradlew downloadApolloSchema (#6097)
  • [gradle-plugin] Use registerJavaGeneratingTask (#6149)
  • [apollo-ast] Add GQLDocument.validate(SchemaValidationOptions) to allow adding external schemas. (#6164)
  • [compiler] Add ApolloCompilerPlugin.schemaDocumentListener() (#6165)
  • [compiler] Pass schema to ApolloCompilerPlugin.schemaListener (#6166)
  • [compiler] Avoid enum value clashing with the getter field (#6093)
  • [compiler] Fix a few additional instances of %L used instead of %N (#6117)
  • [compiler] Escape properties in input builder function body (#6116)
  • [compiler] Provide a more descriptive error message when a resolution of a specific ResolverKey fails (#6136)
  • [compiler] Deprecate @nonnull (#6152)
  • [compiler] Allow mapping scalars to simple generic types (#6158)
  • [tooling] Allow to shutdown SchemaDownloader (#6091)
  • [tooling] Remove warning (#6092)
  • [WebSockets] connectionParams -> connectionPayload (#6103)
  • [WebSockets] add NetworkTransport.closeConnection() (#6105)
  • [BREAKING][runtime] Change NetworkMonitor to expose a StateFlow directly (#6119)
  • [runtime] Add 'OfflineException' as a cause when using failFastIfOffline (#6104)
  • [apollo-api] Fix reading JsonNumber in MapJsonReader (#6141)
  • [cache] Allow to store JsonNumber in Record (#6139)
  • [cache] Fix cascade SQL cache remove loops forever on cyclic references (#6137)
  • [IJ Plugin] Bump pluginUntilBuild to 242 and pluginSinceBuild to 241 (#6111)
  • [IJ Plugin] Add ApolloOneOfGraphQLViolationInspection (#6125)
  • [IJ Plugin] Improve performance of ApolloGraphQLConfigFilePresentInspection and ApolloGraphQLConfigFilePresentAnnotator (#6126)
  • [IJ Plugin] Fix high latency field inspection (#6142)
  • [IJ Plugin] Correctly name Open In items (#6151)
  • [infra] Bump Kotlin to 2.0.10 (#6107)
  • [infra] Bump Kotlin to 2.0.20 (#6131)
  • [infra] Bump develocity (#6128)
  • [infra] Update Apollo Execution (#6138)
  • [infra] Bump develocity (#6144)
  • [infra] Allow compiling the project with Java22 (#6145)
Jul 29, 2024

Apollo Kotlin 4 is a maturity release. It focuses on tooling, stability and making the library more maintainable, so it can evolve smoothly for the many years to come.

While most of the core APIs stayed the same, Apollo Kotlin 4 contains a few binary breaking changes. To account for that, and in order to be more future-proof, we changed the package name to com.apollographql.apollo.

You need to replace all the com.apollographql.apollo3 with com.apollographql.apollo in your codebase.

Thanks again to everyone who provided feedback during the alphas/betas.

Main changes

Changes against 3.8.5

  • #5984 - Add doNotStoreOnDisk()
  • #5982 - RetryOnNetworkErrorInterceptor should be configurable
  • #5971 - writeOperation/writeFragment no longer publish updates by default
  • #5966 - Move apollo-execution out of the main repo
  • #5952 - [IJ Plugin] Cache GraphQL project config
  • #5946 - Sub-protocol not included when opening websocket [4.0.0-beta6]
  • #5933 - [IJ/AS plugin] Internal error: NullPointerException
  • #5929 - Unnecessary AndroidX Multidex library included
  • #5922 - Apply com.apollographql.apollo3 plugin will break the dependencies in Kotlin Multiplatform according to IDEA
  • #5917 - Enabling apollo metadata generation for multi-module codegen causes build cache misses
  • #5901 - A request with any enum having rawValue = null hangs forever
  • #5899 - [IJ Plugin] UI for 'Go to declaration' is too wide
  • #5896 - [IJ Plugin] Cache viewer icon has wrong color in "new ui" theme
  • #5887 - [IJ Plugin] Warn when .graphqlrc files are present
  • #5885 - Cronet request lifecycle not behaving correctly with Apollo.
  • #5884 - [IJ/AS plugin] Internal error: NullPointerException
  • #5834 - SQL cache is unusably slow
  • #5833 - Make apollo-mockserver a separate repository
  • #5832 - MegaIssue: Independant versioning
  • #5827 - [IJ Plugin] Incorrect error when repeating @semanticNonNullField
  • #5819 - "Could not read normalized cache" in AS plugin
  • #5808 - Support for tree shaking in the __Schema.possibleTypes()
  • #5801 - ClassCastException is thrown when building an ApolloClient using a builder in KotlinJS
  • #5799 - isFromCache is potentially confusing
  • #5796 - Make it impossible to pass as input some type which was generated only to preserve forwards compatibility but was not meant to be used as input
  • #5795 - WasmJs support for apollo-adapters
  • #5781 - Codegen: rework how compiled field arguments are generated
  • #5777 - ApolloClient.Builder.okHttpClient() returns null instead of this
  • #5775 - Lazy version of okHttpCallFactory?
  • #5771 - [IJ Plugin] Crash when navigating to GraphQL operation via margin marker
  • #5768 - [IJ/AS plugin] Internal error: NullPointerException
  • #5757 - ApolloParseException is wrapping SocketException, StreamResetException
  • #5753 - [IJ/AS plugin] Internal error: NullPointerException
  • #5745 - Run subscriptions like queries with IDE plugins
  • #5738 - [IJ Plugin] Tweak navigation from GraphQL to generated code
  • #5727 - [Intellij Plugin] Truncate "go to" data
  • #5723 - Remove sendApqExtensions and sendDocument from MutableExecutionOptions
  • #5715 - Make NetworkMonitor work without androidx.startup
  • #5714 - Upgrade IJ platform minVersion
  • #5713 - Make benchmarks a composite build
  • #5712 - generateServiceApolloSources task fails with nondescript NullPointerException when type extension references unknown key field
  • #5697 - Websocket won't reopen on iOS
  • #5667 - Experimental @defer support does not work with AutoPersistedQueryInterceptor
  • #5659 - Use StreamingNSURLSessionHttpEngine by default on Apple
  • #5648 - Megaissue: improvements to WebSockets
  • #5647 - [IJ Plugin] Try the new IntelliJ Platform Gradle Plugin 2.0
  • #5641 - Introspection is broken in the beta
  • #5616 - [IJ Plugin] Send telemetry only for projects using Apollo
  • #5575 - [IJ/AS plugin] Internal error: Throwable
  • #5568 - Disallow @typePolicy on unions
  • #5507 - 🧩 [IJ Plugin] Remove client only directives before sending the query to the server
  • #5500 - [IJ Plugin] v3 -> v4 Migration: add @link imports for used kotlin_labs directives
  • #5481 - [IJ/AS plugin] Internal error: ClassCastException
  • #5468 - Publish apollo-cli
  • #5455 - Build fails after schema file rename when Gradle configuration cache enabled
  • #5449 - [gradle-plugin] download{Service}SchemaFromIntrospection fails
  • #5431 - Support @oneOf for Input Objects
  • #5415 - Compiler plugin API + classloader isolation
  • #5413 - [IJ plugin] Automatically import certain directives
  • #5379 - Allow the cache viewer to sort items more "intelligently" when showing cache entries that have a number at the end
  • #5374 - [IJ Plugin] Inspection to warn when using input types constructors
  • #5372 - [IJ plugin] Normalized cache: reload button for file caches
  • #5345 - [RFC] Remove X-APOLLO-... custom headers
  • #5342 - [IJ/AS plugin] Internal error: IllegalArgumentException
  • #5338 - Unexpected behavior of @include directive on a fragment
  • #5337 - [RFC] Error handling -- @catch & partial data
  • #5331 - [IJ plugin] Quality of life improvements
  • #5329 - [IJ plugin] Sometimes db files are not in the list from "Pull from device"
  • #5312 - useV3ExceptionHandling should populate data even if errors are present
  • #5311 - Warnings are surfaced during build when fragments with params are used in queries
  • #5299 - [IJ/AS plugin] Cache viewer
  • #5266 - [IJ/AS plugin] Internal error: PluginException
  • #5261 - [IJ/AS plugin] Internal error: PluginException
  • #5241 - Apollo Parse Exception - failed to parse
  • #5239 - [IJ/AS plugin] Analytics
  • #5235 - [IJ/AS Plugin] Use JetBrains Marketplace for weekly snapshots instead of Repsy
  • #5233 - NullPointerException for Request with single-quote character
  • #5230 - useV3ExceptionHandling should not throw ApolloGraphQLException
  • #5224 - generateServiceApolloSources crashes if a fragment definition references itself
  • #5221 - Implicit task dependency not working
  • #5220 - [IDE Plugin] Sandbox Button Does Not Carry Over Fragments from other Modules
  • #5217 - Retrying a subscription does not renew the id and may cause an error on the server because the id is already used
  • #5213 - Gradle crash when @typePolicy defined for nonexistant field.
  • #5207 - Add options to not generate data classes
  • #5200 - Subscriptions: support SUBSCRIPTION_SCHEMA_RELOAD
  • #5186 - Cache: Variable defaultValues are not taken into account for cache keys
  • #5173 - [IJ/AS Plugin] Middle click on Fragment definition overrides GraphQL Go to usages.
  • #5172 - [IJ/AS plugin] Ignore id field in Unused field inspection
  • #5171 - Consider migrating generated code to use Enum.entries instead of Enum.values() for Kotlin 1.9 and onwards
  • #5159 - Increase the maximum JSON nesting level, or make it customisable
  • #5112 - :app:generateStorefrontApolloSources Variables used in the query are warned as unused.
  • #5066 - 🧩 [IJ/AS plugin] "Find unused fields" inspection
  • #5057 - [IJ plugin] Quick fix for expensive field: add @defer
  • #5040 - [IJ/AS plugin] Operation renaming improvement
  • #5039 - [IJ/AS plugin] Migration helper for the v4 multi-module syntax
  • #5035 - Android Studio Plugin - Navigate to Query Gutter Icon Missing
  • #5033 - [IJ plugin] "Go to declaration" doesn't offer graphql target when used on an import alias
  • #5028 - [IJ/AS plugin] Feature: Apollo Studio field insights
  • #5000 - Un-minimized query in comment has parse errors
  • #4977 - [IJ/AS plugin] Show errors when mixing .graphql / .graphqls file contents
  • #4942 - [IJ/AS plugin] Don't crash when ToolingModel method are not present
  • #4931 - False positives on unused(?) input fields, Apollo: Use of deprecated input field {{ name }}
  • #4925 - Task downloadFooApolloSchemaFromIntrospection fails to comply with configuration cache
  • #4921 - Support for AGP 8.2.0
  • #4920 - apollo-ast: support merging definitions without validation
  • #4919 - [IJ/AS plugin] Navigation from code to GQL definition
  • #4889 - [IJ/AS plugin] Support both AS stable and IJ stable
  • #4858 - Remove initRuntimeIfNeeded() in Project
  • #4805 - With more than one subscription and network off for long duration, webSocketReopenWhen can take unexpectedly long to establish connection when network is back on.
  • #4797 - Cannot use GQLDocument.toUtf8() on documents that include the extend keyword
  • #4784 - Fragments are skipped when the if condition is a variable with a false default value
  • #4775 - WebSockets: allow changing the serverUrl of WebSocketNetworkTransport
  • #4761 - IntelliJ plugin description, link to terms, etc.
  • #4760 - [IJ/AS plugin] Make the GQL plugin setting to handle Apollo directives always checked
  • #4759 - Automatic "compat" -> "operationBased" migration
  • #4747 - generateOptionalOperationVariables setting is ignored.
  • #4744 - Use Apollo Kotlin inside Apollo Kotlin
  • #4732 - External interfaces for JS interop
  • #4728 - Poor Performance of Kotlin/JS
  • #4711 - RFC: v4 error handling
  • #4710 - RFC: v4 package name
  • #4701 - Kotlin/Wasm
  • #4669 - Unit testing error resolving class
  • #4625 - [IJ/AS plugin] Support for multiple schemas according to configuration
  • #4623 - [IJ/AS plugin v3
  • #4622 - [IJ/AS plugin] Migration helpers v3
  • #4621 - [IJ/AS plugin] Automatic codegen invocation
  • #4620 - [IJ/AS plugin] Project setup
  • #4619 - [IJ/AS plugin] Initial release umbrella ticket
  • #4576 - Android (JAVA)Apollo subscription only onConnected() is called
  • #4574 - js client requests can fail due to inclusion of apollo specific headers
  • #4542 - Allow supplying something other than suspending functions to core builders
  • #4530 - The POM for com.apollographql.apollo3:apollo-rx3-support-java:jar:3.7.1 is missing, no dependency information available
  • #4519 - Update to SQLDelight 2
  • #4518 - Enforce validation of operation directives
  • #4516 - 🐘 Gradle config: mandate service name
  • #4504 - Allow custom SqlDriver to support multi-platform encryption
  • #4416 - enable configuration cache
  • #4350 - maven-publish doesn't play well with -apollo modules generated when generateApolloMetadata is used
  • #4325 - [Umbrella issue] modernize build system
  • #4283 - [Umbrella issue] Better Java support in Apollo Kotlin
  • #4205 - Validation for custom schema directives
  • #4171 - 🧹 4.0 cleanups
  • #4160 - 🐜 Multiplatform AST parser
  • #4150 - Deprecate dispose() methods and instead implement okio.Closeable
  • #4062 - Deprecate ApolloCompositeException with Error level and use suppressed exceptions instead
  • #4003 - ApolloCall execute / toFlow / exception handling improvements
  • #3890 - Passing executionContext to the platform engine
  • #3751 - Automatic "codegenModels" migration
  • #3733 - @nonull could have surprising effects in error cases
  • #3694 - [umbrella issue] Java Runtime
  • #3283 - Trigger a compilation error on name clashes
  • #3152 - Provide module information (JPMS)
  • #3143 - Implement toString for InputTypes
  • #2823 - Cache and connection restore for Subscription
  • #2783 - ApolloParseException caused by SocketTimeoutError while reading response body
  • #2765 - Subscription switched to DISCONNECTED
  • #2673 - [Compiler] Validate operation directives
  • #2520 - Feature request: Resilient Parsing
  • #2079 - Ktlint should not warn on generated Apollo code
  • #1692 - On the fly code generation
  • #650 - Create Android Studio Plugin
Jul 22, 2024

We're on the road to v4 with this second release candidate which includes a few minor tweaks as well as one new feature.

Note: in v4.0.0-rc.1 apollo-debug-server and apollo-tooling depended on com.apollographql.apollo3 artifacts. This is no longer the case with v4.0.0-rc.2, where all dependencies are under the com.apollographql.apollo group id.

Add memoryCacheOnly (#6049)

.memoryCacheOnly(true) can be set on calls to read and store records in the memory cache only even when a persistent cache is configured. This can be useful in scenarios where long term storage isn't needed and performance is important.

  • [gradle-plugin] Use a better warning for Service.schemaFile users (#6036)
  • [all] Update apollo-kotlin-execution (#6040)
  • [IJ Plugin] Add com.apollographql.apollo:apollo-api-jvm to dependencySupport (#6039)
  • [all] Update to Gradle 8.9 (#6056)
  • [gradle-plugin] Undeprecate schemaFile (#6055)
  • [gradle-plugin] Disable service-loading ApolloCompilerPlugin (#6059)
Jul 11, 2024

Version 3.8.5 is a maintenance release. New developments happen in the 4.x versions.

  • [all] Bump okio to 3.9.0 (#5868)
  • [runtime] Adding checks for json end_document in http transport (#5894)
  • [runtime] Adding checks for json end_document in http batching interceptors (#5892)
  • [codegen] Fix mapping of the builtin Float scalar type (#6047)
  • [normalized-cache] SqlNormalizedCacheFactory make sqldriver public to support Sqlcipher data encryption. (#5972)
Jul 8, 2024

New package name & evolution policy

We changed the package name from com.apollographql.apollo3 to com.apollographql.apollo for version 4. This is a safe default for the many years to come and works well with our new evolution policy.

If you are updating from version 3 or an alpha/beta version 4, you need to replace all com.apollographql.apollo3 with com.apollographql.apollo

Apollo galaxy

As part of this release, some of the non-core artifacts have been moved to separate coordinates and GitHub repositories. Moving forward, this will allow us to iterate faster on those artifacts while keeping the core ones more maintainable.

Some of the existing symbols are kept as deprecated to ease the transition (like MockServer for an example). Others (the -incubating ones) have been removed, and you need to update them now.

You can read more in the migration guide.

All changes

  • [BREAKING][all] Change package name to com.apollographql.apollo
  • [BREAKING][all] Remove incubating compose support (moved to a separate repo, see migration guide)(#5987)
  • [BREAKING][all] Remove incubating apollo-cli (moved to a separate repo, see migration guide)(#5986)
  • [BREAKING][all] Remove incubating normalized cache (moved to a separate repo, see migration guide)(#5985)
  • [BREAKING][all] Nullability: update nullability directives to v0.4 (#6002)
  • [BREAKING][all] Suffix ApolloStore write/publish overloads with Sync to avoid them taking precedence over their suspend counterparts (#5976)
  • [NEW][cache] SqlNormalizedCacheFactory make sqldriver public to support Sqlcipher data encryption. (#5973)
  • [NEW][runtime] Add ApolloClient.Builder.retryOnErrorInterceptor (#5989)
  • [adapters] Deprecate apollo-adapters (moved to a separate repo, see migration guide)(#6012)
  • [mockserver] Deprecate com.apollographql.apollo3.mockserver.MockServer (moved to a separate repo, see migration guide)(#5943)
  • [🐘gradle-plugin] Rename the multi-module configurations (#6027)
  • [IJ Plugin] Tweak cache name display for Apollo 3, 4, and incubating (#6026)
  • [compiler] remove unused argument to scalarAdapterInitializer() (#5996)
  • [java] Use published version of the Java support libs (#5991)
  • [runtime] Deprecate apollo engine ktor and publish engine tests (#5988)
  • [mpp-utils] Cleanup mpp utils (#5980)
  • [CI] use gradle/actions/setup-gradle instead of gradle-build-action (#5981)
  • [infra] Update to develocity API (#5967)
  • [incubating cache] Add a CacheKeyApolloResolver based on ApolloResolver (incubating) (#5970)
  • [mockserver] Robustify TCP server (#5968)
  • [runtime] adding checks for json end_document in http batching interceptors (#5893)
  • [IJ plugin] Cache ApolloKotlinService into project settings (#5962)
  • [IJ plugin] Avoid a ConcurrentModificationException occurring in conjunction to the IJ Platform Gradle plugin. (#5959)
  • [websockets] Send Sec-WebSocket-Protocol (#5948)
Jun 5, 2024

Main changes:

  • #5931: This version is built with K2. You need Kotlin 1.9+ on the JVM to build against it and Kotlin 2.0 for other platforms.
  • #5865: ApolloCompilerPluginProvider is introduced to allow passing arguments to compiler plugins. See the compiler plugins documentation for more details.

👷‍ All changes

[testing] Use com.apollographql.mockserver.MockServer (#5939) [testing] Simplify our implementation of runTest (#5935) [testing] Prepare apollo-testing-support to new MockServer (#5934) [runtime] Remove multidex library (#5930) [all] Bump languageVersion/apiVersion to Kotlin 2.0 (#5931) [codegen] fix mapping of the builtin Float type (#5928) [IJ Plugin] Add inspection to warn about the presence of a GraphQL config file (#5908) [codegen] Add a null-check to java enum safeValueOf (#5904) [gradle-plugin] Remove eager configuration (#5923) [gradle-plugin] sort input files (#5919) [IJ Plugin] Suppress GraphQLDuplicateDirective for certain directives (#5910) [adapters] Add KtorHttpUrlAdapter (#5915) [IJ Plugin] Add a "new UI" compatible icon (#5906) [IJ Plugin] Operation and fragment definition rename (#5912) [IJ Plugin] Add @link directives to extra.graphqls during v3->v4 migration (#5909) [IJ Plugin] Remove GraphQL IJ plugin issue workaround (#5907) [cache] Pagination: use "field key" instead of "field name" (#5898) [IJ Plugin] Improve the presentation of GraphQL elements when navigating to them (#5900) [IJ Plugin] Include subfolders when contributing GraphQL config (#5871) [runtime] Remove existing interceptors from ApolloClient.Builder before adding new ones (#5858) [codegen] Add ApolloCompilerPluginProvider (#5865) [runtime] Clear current ApolloStore related interceptors when calling .store() on builder (#5857) [cache] Call through to loadRecords from the MemoryCache to the SQL one (#5848) [runtime] deprecate operationIdGenerator (#5850)

Apr 30, 2024

Version 3.8.4 is a maintenance release with one bug fix and 2 performance improvements. New developments happen in the 4.x versions.

  • [java-runtime] Fix ApolloClient.Builder.okHttpClient() returns null instead of this (#5860)
  • [normalized-cache] Use a single transaction when using MemoryCache chaining (#5861)
  • [normalized-cache] Call through to loadRecords from the MemoryCache to the SQL one (#5863)
Apr 23, 2024

SQL cache performance improvements

If you're using a chained memory + SQL cache, #5840 makes sure cache writes are wrapped in a transaction, making them much faster.

Apollo Compiler Plugins

Plugin is renamed to ApolloCompilerPlugin. There is a new documentTransform API as well as other fixes. More details in the compiler plugins documentation.

Experimental WebSockets

A new .websocket package is available that makes it easier to retry WebSockets and handle errors. More details and migration guide in the experimental websockets documentation.

ApolloIdlingResource is deprecated

We recommend using reactive patterns to test your UI instead. See this article about ways to do so.

Removed androidx.startup dependency

androidx.startup was introduced in beta.5 but is problematic for unit tests and other cases. beta.6 removes that dependency. More details in the network connectivity documentation.

WasmJS support for apollo-adapter

You can see Wasm in action at https://wasm.confetti-app.dev/

Threading changes

In a effort to minimize the number of thread switches, the whole request is now run in the same dispatcher. See Threading.md for more details.

Contributors 💙

Many thanks to @joreilly, @ychescale9 and @japhib for their contributions to this release 💙!

👷‍ All changes

  • [normalized-cache]: use a single SQL transaction when using MemoryCache chaining (#5840)
  • [compiler] expose apollo-ast as an api dependency (#5838)
  • [compiler] Rename Plugin to ApolloCompilerPlugin and add error message for bad configurations (#5821)
  • [IJ Plugin] Fix pulling file from device not working on AS Koala (#5822)
  • [compiler] Add @ApolloEnumConstructor and make enum as sealed class Unknown constructor opt-in (#5813)
  • [runtime] Move ApolloParseException to ApolloNetworkException (#5816)
  • [normalized-cache] Let isFromCache be about the ApolloResponse (#5805)
  • [compiler] Add DocumentTransform API (#5809)
  • [idling-resource] Deprecate ApolloIdlingResource (#5817, #5764)
  • [runtime] Share the default OkHttpBuilder (#5811)
  • [runtime] [BREAKING] change isOnline to a suspend fun
  • [adapters] Support Kotlin/Wasm for apollo-adapters (#5803)
  • [all] Bump Kotlin to 2.0.0-RC1 (#5802)
  • [Codegen] Add CompiledArgumentDefinition (#5797, #5837)
  • [runtime] Merge experimental WebSocketNetworkTransport in apollo-runtime (#5790)
  • [normalized-cache] Cache pagination: add FieldNameGenerator and EmbeddedFieldsProvider (#5772)
  • [runtime] Support configuring ApolloClient with lazily initialized Call.Factory. (#5784)
  • [runtime] fix ApolloClient.Builder.okHttpClient() returns null instead of this (#5778)
  • [normalized-cache] Fix variable coercion in lists. Absent variables are coerced to null (#5773)
  • [IJ Plugin] Fix an NPE (#5770)
  • [runtime] Simplify ApolloCall (#5765)
  • [runtime] remove androidx.startup dependency (#5761, #5720)
  • [compiler] Bump kotlin_labs definitions to v0.3 (#5762)
  • [Pagination] Support nodes in Connection types (#5754)
  • [compiler] Directive validation is now enforced by default (#5758)
  • [cache] Make ApolloStore.publish() suspend (#5755)
  • [runtime] Change the dispatcher earlier in the chain (#4319)
  • [IJ Plugin] Add an advanced setting to include generated code references in GraphQL "Go To Declaration" (#5743)
  • [IJ Plugin] Fix presentation of Kotlin elements when navigating to them from GraphQL (#5739)
  • [IJ Plugin] Consider all Gradle projects recursively (#5734)
  • [runtime] Deprecate ApolloClient.Builder.addInterceptors() (#5733)
  • [all] use jdk-release (#5731)
  • [http-cache] Ignore IOException when calling ApolloHttpCache.remove (#5729)
  • [IJ plugin] Bump platformVersion and pluginSinceBuild from 232 to 233 (#5726)
  • [runtime] add ApolloClient.failFastIfOffline (#5725)
  • [all] Introduce "filesystem" sourceSet and use okio 3.9.0 (#5719)
  • [runtime] Do not use Ktor in Js HttpEngine, use fetch directly instead (#5702)
Mar 20, 2024

Version 3.8.3 is a maintenance release with two new convenience APIs and a Kotlin update. New developments happen in the 4.x versions.

Note: because Apollo Kotlin now depends on kotlin-stdlib version 1.9, you need the 1.8+ Kotlin compiler to compile your project.

  • [all] update Kotlin to 1.9 (#5412)
  • [runtime] Add ApolloClient.Builder(ApolloHttpCache) (#5638) (#5640)
  • [runtime] Allow buildPostBody to write operation extensions (#5631)
  • [runtime] compose support: Catch exceptions and expose them in .exception (#5018)
  • [http-cache] Ignore IOException when calling ApolloHttpCache.remove (#5730)
  • [all] Add deprecations on symbols that are getting removed in v4 (#5746)
Mar 12, 2024

Main changes:

  • Apollo compiler plugins: The GraphQL compiler now has APIs that you can use to customize the generated code. This can be used for changing visibility of some symbols, renaming them or more generally customizing the output for any advanced use cases. Moving forward, Apollo compiler plugins are the preferred way to customize operation IDs as well as package names and both PackageNameGenerator and OperationOutputGenerator are deprecated. See the documentation page about Apollo compiler plugins for more details.
  • Reduced lock contention in apollo-normalized-cache-incubating: the incubating normalized cache now uses lock-free memory structures inspired by guava and MobileNativeFoundation/Store. We have seen improvements by up to 20% in some scenarios. Please share your numbers if you notice any positive (or negative) change.
  • Nullability directives: The version of the supported nullability directives was bumped from 0.1 to 0.3 (See apollographql/specs#42 and apollographql/specs#48). If you are using @semanticNonNull or @catch you should bump your @link directives to use 0.3. See the nullability documentation page for more details.
  • New snapshot repository for the IntelliJ/Android Studio plugin: The repository to use for the weekly snapshots has changed. You can now use https://go.apollo.dev/ij-plugin-snapshots to get the latest weekly snapshots. (#5600)
  • Multi-version KDoc: The published KDoc now includes both v3 and v4 versions.

Many thanks to @ribafish, @molundb, @mboyd1993, @rohandhruva and @baconz for their help in this release 💙!

👷‍ All changes

  • [mockserver] Add MockServer.enqueueError() and MockServer.assertNoRequest() (#5694)
  • [runtime] Implement NetworkMonitor for apple platforms (#5691)
  • [runtime] Add NetworkMonitor (#5690)
  • [runtime] Add ApolloClient.retryOnError(Boolean) (#5685)
  • [websockets-network-transport-incubating] Publish apollo-websocket-network-transport-incubating (#5693)
  • [normalized-cache-incubating] Use Store Cache and merge optimistic cache with Memory cache (#5651)
  • [runtime] Fix ApolloClient.Builder if the Builder is mutated by the caller after calling build() (#5683)
  • [websockets-network-transport-incubating] Introduce incubating WebSocketNetworkTransport (#5678)
  • [websockets-network-transport-incubating] Introduce incubating WebSocketEngine (#5676)
  • [runtime] Don't assume a single emission in AutoPersistedQueryInterceptor (#5677)
  • [runtime] Use expect funs instead of expect classes for DefaultHttpEngine (#5672)
  • [runtime] Fix JS websocket throws an ISE on error on Safari and Firefox (#5670)
  • [runtime] Use the streaming HttpEngine by default on Apple (#5671)
  • [intellij-plugin] Only send telemetry for Apollo Kotlin projects (#5663)
  • [gradle-plugin] Use Gradle normalization instead of ours (#5636)
  • [execution] Fix converting int and floats to their Kotlin value (#5637)
  • [runtime] Add ApolloClient.Builder(ApolloHttpCache) (#5638)
  • [gradle-plugin] Use com.android.lint Gradle rules (#5639)
  • [all] Update coroutines to 1.8.0 (#5626)
  • [runtime] Allow buildPostBody to write operation extensions (#5630)
  • [compiler] Add support for @catch on fieldDefinitions, interfaces and objects (#5623)
  • [all] Bump Kotlin to 2.0.0-Beta4 (#5624)
  • [normalized-cache-incubating] Cache lock changes (#5608)
  • [rx-support] Keep rx-support as DeprecationLevel.Error (#5610)
  • [gradle-plugin] Add dependsOn(dependencyNotation, bidirectional) (#5606)
  • [gradle-plugin] Fix a regression in alwaysGenerateTypesMatching where all types would be generated by default (#5605)
  • [️compiler] Add Apollo compiler plugin API (#5604, #5599, #5591, #5589, #5588, #5582, #5573, #5561, #5560, #5557, #5556, #5554, #5516, #5589)
  • [intellij-plugin] Publish the IJ plugin snapshots to the JetBrain Marketplace (#5600)
  • [runtime] HTTP Headers: remove X-APOLLO-OPERATION-NAME, X-APOLLO-OPERATION-ID and the multipart boundary (#5533)
  • [gradle-plugin] use Worker API and ServiceLoader (#5590)
  • [gradle-plugin] deprecate schemaFile and sourceFolder (#5581)
  • [gradle-plugin] configuration cache and lazy properties for schema files (#5580)
  • [️compiler] Track semanticNonNull spec (#5577)
  • [gradle-plugin] bump minimum required Gradle version to 8.0 (#5579)
  • [ast] Validate repeatable directives (#5574)
  • [compiler] Don't automatically add key fields to union selections (#5562)
  • [runtime] Fix disabling batching by default (#5552)
  • [gradle-plugin] Select all types in pre-introspection query (#5547)
  • [normalized-cache-api] Remove unnecessary suspend from ApolloStore functions (#5541)
  • [all] One more step towards K2 but blocked on https://youtrack.jetbrains.com/issue/KT-21846 (#5536)
  • [all] Target Java17 for Android .aars and Java11 for apollo-gradle-plugin.jar (#5534)
  • [compiler] Remove old generateAsInternal code (#5526)
  • [compiler] Lock down apollo-compiler API (#5524)
  • [normalized-cache-sqlite] Use windowSizeBytes argument of AndroidSqliteDriver (#5523)
  • [intellij-plugin] Strip Apollo client directives before executing operations (#5517)
  • [execution] Fix converting GraphQL Float values to Kotlin (#5511)
  • [intellij-plugin] Don't show a visible task with progress bar while fetching the Apollo Conf (#5501)
  • [intellij-plugin] Inspection: missing directive import (#5494)
  • [intellij-plugin] Use recent version of slf4j to avoid a classloader issue (#5495)
  • [normalized-cache-sqlite] Allow custom SupportSQLiteOpenHelper.Callback in the SqlNormalizedCacheFactory (#5488)
  • [mockserver] Allow to set the content-type of String responses (#5489)
  • [debug-server] Start LocalServerSocket on background thread, and handle exception (#5493)
  • [cli-incubating] Publish apollo-cli-incubating again (#5486)
  • [intellij-plugin] Don't suggest v4 migration until it is stable (#5477)
  • [tooling] bump version of Apollo to 4.0.0-beta.3 (#5452)
  • [debug-server] Don't crash if ApolloDebugServerInitializer is not run (e.g. in unit tests) (#5484)
  • [intellij-plugin] Add debugging logs around the cache viewer (#5475)
  • [debug-server] Debug server: don't crash when a client has no caches (#5479)
  • [gradle-plugin] add apollo.deps (#5460)
Dec 12, 2023

✨ Initial Wasm support (#5458)

This release adds initial support for WebAssembly by adding the wasmJs target.

Executing queries/mutations is working but this target is experimental (Kotlin/Wasm is Alpha) and has multiple limitations:

  • No WebSockets
  • No caching
  • No support for WASI or NodeJS

🪲 Bug fix

Downloading a schema from introspection (./gradlew downloadServiceSchemaFromIntrospection) got broken in the previous release (#5449) and is now fixed.

👷‍ All changes

Dec 5, 2023

Many thanks @chris-hatton and @sdfgsdfgd for contributing this version 💙

⚠️ we're aware of a regression in downloadApolloSchema, we'll make a new release soon.

🧩 IDE plugin: in-memory cache support

The normalized cache viewer can now display the contents of your in-memory cache. To do so, it relies on a debug server that you need to run in your debug builds:


val apolloClient = ApolloClient.Builder()
    .serverUrl("https://example.com/graphql")
    .build()

if (BuildConfig.DEBUG) {
  ApolloDebugServer.registerApolloClient(apolloClient)
}

You can read more about it in the "Apollo debug server" documentation page.

🎣 Experimental @catch and @semanticNonNull support

@catch makes it possible to model GraphQL errors as FieldResult Kotlin classes giving you inline access to errors:

query GetUser {
  user {
    id
    # map name to FieldResult<String?> instead of stopping the parsing
    name @catch
    avatarUrl
  }
}

@semanticNonNull is a better @nonnull. @semanticNonNull makes it possible to mark a field as null only on error. The matching Kotlin property is then generated as non-null:

# mark User.name as semantically non-null
extend type User @semanticNonNull(field: "name")

Both those directives are experimental and require opt-in of the nullability directives

You can read more about them in the "handle nullability" documentation page.

1️⃣ Experimental @oneOf support

@oneOf introduces input polymorphism to GraphQL:

input PetInput @oneOf {
  cat: CatInput
  dog: DogInput
  fish: FishInput
}

input CatInput { name: String!, numberOfLives: Int }
input DogInput { name: String!, wagsTail: Boolean }
input FishInput { name: String!, bodyLengthInMm: Int }

type Mutation {
  addPet(pet: PetInput!): Pet
}

With @oneOf, only one of cat, dog or fish can be set.

@oneOf support is automatically enabled if your schema has the @oneOf directive definition.

You can read more about it in the @oneOf RFC

👷‍ All changes

[all] @oneOf support (#5394, #5388) [all] @catch and @semanticNonNull support (#5405) [all] Take default values into account when computing field cache keys (#5384) [all] Bump Kotlin to 2.0.0-Beta1 (#5373)

[IJ Plugin] Add 'Input class constructor issue' inspection (#5427) [IJ plugin] Update v3->v4 migration following API tweaks (#5421) [IJ Plugin] Report invalid oneOf input object builder uses (#5416) [IJ Plugin] Add inspection for @oneOf input type constructor invocation (#5395) [IJ plugin] Make the refresh button work with all normalized cache sources. (#5400) [IJ Plugin] Cache viewer: take numbers into account in key sorting (#5396) [IJ Plugin] Bump pluginUntilBuild to 233 (#5377) [IJ Plugin] Telemetry: don't use a libraries changed listener (#5361) [IJ Plugin] Cache viewer: add cache size to selector (#5357) [IJ plugin] Use apollo-debug-server to retrieve normalized caches (#5348) [IJ plugin] Cache viewer: "Pull from Device" modal dialog instead of action menu (#5333) [IJ Plugin] Fix v3->v4 migration with ApolloCompositeException (#5330)

[runtime] remove some of the ApolloResponse.Builders (#5426) [runtime] Add a few symbols as ERROR deprecation for the migration (#5422) [runtime] Add executeV3 + toFlowV3 (#5417) [runtime] Revive dataAssertNoErrors (#5419) [runtime] Allow no data and no exception in case of GraphQL errors (#5408) [runtime] Expose ExecutionContext to HttpEngine and add OkHttp helpers (#5383) [runtime] Improve deprecation messages (#5411) [runtime] Go back to just one Adapter class (#5403) [runtime] Fix Optional.getOrElse (#5399)

[compiler] Remove kotlin-labs-0.1 directives (#5404) [compiler] Throw a better exception than NullPointerException if a value is missing (#5402) [compiler] ExecutableValidationResult is returned by validateAsExecutable() and cannot be @ApolloInternal (#5406) [compiler] Rework the IrType hierarchy (#5392) [compiler] remove CCN (#5387) [compiler] Remove antlr (#5336) [compiler] Tweak description javadoc, there is no need to use the same escaping as Kotlin (#5424)

[mockserver] Support setting port for Apollo MockServer (#5389) [mockserver] Add WebSocket support to the MockServer (#5334) [tools] Implement 2-step introspection (#5371) [apollo-execution] Allow to pass arguments to the root types (#5352) [apollo-ksp] Initial support for interfaces (#5351)

Oct 23, 2023

We're continuing to progress towards the stable release of Apollo Kotlin v4 with this 2nd beta, which contains a few bug fixes and a new normalized cache viewer in the IDE plugin.

This is a great time to try out the new version and report any issues you might find!

🧩 IDE plugin: normalized cache viewer

The IDE plugin now has a graphical tool to inspect a normalized cache database. It lets you browse the records and see their contents. This is useful to debug cache issues, or to understand how the normalized cache works.

The tool is available from View | Tool Windows | Apollo Normalized Cache.

More information about the plugin can be found here.

👷‍ All changes

  • Fragment variables: fix false warning about unused variables (#5290)
  • Fix reading fragment with include directives from the cache (#5296)
  • Fix partial data throwing with useV3ExceptionHandling and normalized cache (#5313)
  • Unbreak benchmarks (#5284)
  • Bump to gradle 8.4 and IJGP 1.16.0 (#5286)
  • Add apollo-execution and apollo-ksp (#5281)
  • [IJ plugin] Normalized cache viewer: UI (#5298)
  • Fix build (#5301)
  • Bump to Kotlin 1.9.20-RC (#5300)
  • [IJ plugin] Telemetry: networking (#5285)
  • [IJ plugin] Cache viewer: record quick filter (#5302)
  • Update release script to update versions in IJ plugin (#5303)
  • MockServer API cleanup (#5307)
  • Remove some warnings (#5308)
  • Use the default hierarchy template (#5309)
  • [IJ plugin] Cache viewer: open/read db file (#5306)
  • [IJ plugin] Cache viewer: add back/forward buttons, and copy action (#5310)
  • Fix NSURL tests on recent apple OSes (#5315)
  • [IJ plugin] Cache viewer: pull file from attached devices (#5314)
  • Make more of MockServer common code, only abstract the socket part (#5316)
Oct 2, 2023

The first beta of the next major version of Apollo Kotlin is here!

While there still may be a few API changes before the stable release, we are getting close and this is a great time to try out the new version and report any issues you might find!

💙️ External contributors

Many thanks to @baconz and @hbmartin for their awesome contributions to this release!

❗️ Schema Nullability Extensions (#5191)

The GraphQL community is working hard at making it easier to work with nullability in GraphQL.

In Apollo Kotlin, it is now possible to change the nullability of fields and list elements at the schema level using schema extensions. This is useful if you believe the schema made a field nullable for error reasons only and you don't want to handle those errors. In these cases, the whole query will return as an error.

Given the following SDL:

# schema.graphqls
type Query {
  random: Int
  list: [String]
  required: Int!
}

You can extend it like so:

# extra.graphqls
extend type Query {
  # make random non-nullable
  random: Int!
  # make list and list items non-nullable
  list: [String!]!
  # make required nullable
  required: Int
  # add a new field
  new: Float
}

📜️ Code generation

generateMethods option to control which model methods are generated (#5212)

By default all Kotlin models, operations, fragments, and input objects are generated as data classes. This means that the Kotlin compiler will auto-generate toString, equals hashCode, copy and componentN. If you don't think you need all of those methods, and/or you are worried about the size of the generated code, you can now choose which methods to generate with the generateMethods option:

apollo {
  service("service") {
    // Generates equals/hashCode
    generateMethods.set(listOf("equalsHashCode"))
    // Also generates toString, equals, and hashcode
    generateMethods.set(listOf("equalsHashCode", "toString"))
    // Only generates copy
    generateMethods.set(listOf("copy"))
    // Generates data classes (the default)
    generateMethods.set(listOf("dataClass"))
  }
}

Other codegen tweaks

  • Enum.values() is no longer recommended when using Kotlin 1.9+ and the generated code now uses entries instead (#5208)
  • Deprecation warnings in generated code are suppressed (#5242)

🧩 IntelliJ plugin

  • You can now suppress reported unused fields, by adding a comment on the field, or by configuring a regex in the settings (#5195, #5197)
  • Opening an operation in Sandbox now includes all referenced fragments (#5236)

🪲 Bug fixes

  • Detect cyclic fragment references (#5229)
  • Fix Optional<V>.getOrThrow() when V is nullable (#5192)
  • useV3ExceptionHandling only throws when there are no errors populated (#5231)
  • Tweak the urlEncode algorithm (#5234)
  • Add a validation for adding keyFields on non-existent fields (#5215)
  • Fix logging when the response body is a single line (#5254)

👷‍ All changes

  • [Infra] Count tests in CI (#5181)
  • Test: remove flake (#5167)
  • Use compilations instead of multiple mpp targets for java codegen tests (#5164)
  • [IJ plugin] Add fragment usages when going to fragment declaration (#5189)
  • Add mergeExtensions and toFullSchemaGQLDocument (#5162)
  • Fix Optional<V>.getOrThrow() when V is nullable (#5192)
  • Schema Nullability Extensions (#5191)
  • [IJ plugin] Add inspection suppressor to allow suppression on fields (#5195)
  • Add PQL support to registerOperations {} (#5196)
  • Add WebSocketMockServer and tests for WebSocketEngine (#5187)
  • [IJ plugin] Add options to ignore fields when reporting unused fields (#5197)
  • Unbreak benchmarks (#5202)
  • Bump uuid and okio (#5204)
  • [IJ plugin] Update references to 4.0.0-alpha.2 to 4.0.0-alpha.3 (#5205)
  • Use entries instead of values() when using Kotlin 1.9 (#5208)
  • Add generateMethods options to control which methods are generated on "data" classes (#5212)
  • Add a validation for adding keyFields on non-existent fields (#5215)
  • Engine tests: use compilations to share logic between ktor/default engines (#5216)
  • Skip Dokka during development (#5219)
  • Introduce JsonReader.toApolloResponse (#5218)
  • Add tests for empty objects in last chunk (#5223)
  • useV3ExceptionHandling should only throw when there are no errors populated (#5231)
  • Tweak the urlencode algorithm (#5234)
  • [IJ plugin] Gather referenced fragments when opening in Apollo Sandbox (#5236)
  • Kotlin 1.9.20-Beta (#5232)
  • Suppress Kotlin warnings in generated code (#5242)
  • Add Optional.getOrElse(value) (#5243)
  • Add Error.Builder() (#5244)
  • Add APOLLO_RELOCATE_JAR and APOLLO_JVM_ONLY (#5245)
  • Detect cyclic fragment references (#5229)
  • [IJ plugin] Telemetry: collect properties (#5246)
  • Bump kotlin to 1.9.20-Beta2 (#5249)
  • [IJ plugin] Telemetry: settings and opt-out dialog (#5247)
  • [IJ plugin] Telemetry: add IDE/plugin related properties and events (#5250)
  • Fix cyclic fragment detection (#5252)
  • [IJ plugin] Add an ErrorReportSubmitter (#5253)
  • Logging a single line response body by @hbmartin in https://github.com/apollographql/apollo-kotlin/pull/5254
  • [IJ plugin] Schedule send telemetry (#5256)
  • Allow MapJsonReader to read non-Map instances (#5251)
  • [IJ plugin] Fix a crash when loading plugin (#5260)
  • Tweaks for K2 (#5259)
  • Update apollo published (#5263)
Aug 8, 2023

A lot of additions to the IntelliJ plugin as well as a new GraphQL parser, a new Ktor multiplatform engine and more!

💙 External contributors 💙

Apollo Kotlin wouldn't be where it is today without the awesome feedback, discussions and contributions from community members. Specifically in this release, we want to give a huge THANK YOU to: @Emplexx, @sonatard, @yt8492, @mayakoneval, @Meschreiber, @pcarrier and @ashare80

🧩 IntelliJ plugin

👓 Unused field inspection (#5069)

The IntelliJ plugin now detects unused fields in your queries and greys them out:

https://github.com/apollographql/apollo-kotlin/assets/372852/6a573a78-4a07-4294-8fa5-92a9ebb02e6c

v4 migration

The IntelliJ plugin can migrate most of your codebase to v4. To try it out, go to:

Tools -> Apollo -> Migrate to Apollo Kotlin 4

Because Kotlin is such a rich language and we can't account for all possible ways to configure your build, you might have to do some manual tweaks after the migration. But the plugin should handle most of the repetitive tasks of migrating.

☁️ Schema download (#5143)

If you configured introspection, you can now download your schema directly from IntelliJ

<img src="https://github.com/apollographql/apollo-kotlin/assets/372852/3a15f587-b057-4df5-82c0-2e0b0247c203" width=250/>

📖 documentation

The IntelliJ plugin now has its own dedicated documentation page.

Consult it to find out everything you can do with the plugin as well as installation instructions.

🌳 Multiplatform Apollo AST (#5047)

Apollo AST, the GraphQL parser powering Apollo Kotlin is now a manually written recursive descent parser, compared to an automatically generated Antlr parser before. Benchmarks show a x2 to x3 speed improvement and the parser also now supports all platforms Apollo Kotlin supports.

❗❓ Initial Client Controlled Nullability (CCN) support (#5118)

Client Controlled Nullability (CCN) is a GraphQL specification RFC aiming at making it easier to work with GraphQL in type safe languages like Kotlin and Swift.

To use CCN, use the ! and ? CCN modifiers in your queries:

query GetUser {
  user {
    id
    # name is required to display the user
    name!
    # phoneNumber is optional
    phoneNumber?
  }
}

The RFC is still in early stages and requires server support. The API and final shape of the RFC might still change. By adding support in Apollo Kotlin, we're hoping to unblock potential users and gather real life feedbacks helping the proposal move forward.

📡 Ktor engine (#5142)

Apollo Kotlin now ships a apollo-engine-ktor that you can use to replace the default HTTP and WebSocket engines of ApolloClient. To use it, add apollo-engine-ktor to your dependencies:

dependencies {
  implementation("com.apollographql.apollo3:apollo-engine-ktor")
}

And configure your client to use it:

val apolloClient = ApolloClient.Builder()
    .serverUrl("https://example.com/graphql")
    .httpEngine(KtorHttpEngine())
    .webSocketEngine(KtorWebSocketEngine())
    .build()

👷 generateInputBuilders (#5146)

For Kotlin codegen, Apollo Kotlin relied on constructors with default arguments. While this works well in most cases, default arguments lack the ability to distinguish between null and absent meaning you have to wrap your values in Optional before passing them to your constructor. If you had a lot of values, it could be cumbersome:

val input = SignupMemberInput(
    dob = Utils.changeDateFormat(user.dobMMDDYYYY, "MM/dd/yyyy", "yyyy-MM-dd"),
    firstName = Optional.Present(user.firstName),
    lastName = user.lastName,
    ssLast4 = Optional.Present(user.ssnLastFour),
    email = user.email,
    cellPhone = Optional.Present(user.phone),
    password = user.password,
    acceptedTos = true,
    formIds = Optional.Present(formIds),
    medium = Optional.Present(ConsentMediumEnum.android)
)

To generate Kotlin Builders, set generateInputBuilders to true in your Gradle file:

apollo {
  service("api") {
    packageName.set("com.example")

    generateInputBuilders.set(true)
  }
}

With Builders, the same above code can be written in a more fluent way:

val input = SignupMemberInput.builder().apply {
    dob(Utils.changeDateFormat(user.dobMMDDYYYY, "MM/dd/yyyy", "yyyy-MM-dd"))
    firstName(user.firstName)
    lastName(user.lastName)
    ssLast4(user.ssnLastFour)
    email(user.email)
    cellPhone(user.phone)
    password(user.password)
    acceptedTos(true)
    formIds(formIds)
    medium(ConsentMediumEnum.ANDROID)
}.build()

👷‍ All changes

  • [IJ plugin] Update platformVersion to 223 (#5166)
  • [runtime] Add Ktor Engine (#5142)
  • [tests] Add a test for field names that have the same name as an enum type (#5158)
  • [api] Remove limitation on the JSON nesting. If the JSON is way too nested, an OutOfMemory exception will happen (#5161)
  • [ast] add HasDirectives to all things with directives (#5140)
  • [compiler] add a test for types named Object (#5156)
  • [ast] Add a special comment to disable the GraphQL intelliJ plugin inspection (#5154)
  • [IJ plugin] Inspection to suggest adding an introspection block (#5152)
  • [compiler] Better KDoc escape (#5155)
  • [ast] Allow explicit CCN syntax (#5148)
  • [compiler] Add generateInputBuilders (#5146)
  • [infra] Update KotlinPoet (#5147)
  • [infra] update Gradle to 8.3-rc-3 (#5149)
  • [IJ plugin] Add a Download Schema action (#5143)
  • [runtime] Remove ChannelWrapper (#5145)
  • [IJ Plugin] Suggest Apollo 4 migration from version catalog and build.gradle.kts dependencies (#5141)
  • [IJ plugin] v3->v4 migration: add useV3ExceptionHandling(true) to ApolloClient.Builder(). (#5135)
  • [IJ plugin] Improve compat->operationBased migration (#5134)
  • [IJ plugin] Avoid a crash caught in inspection (#5139)
  • [ast] add GQLNamed and GQLDescribed on all types that have a name or a description (#5127)
  • [ast] Omit scalar definitions from SDL (#5132)
  • [infra] Use SQLDelight 2.0.0 (#5133)
  • [IJ Plugin] Don't report redefinitions of built-in types as errors (#5131)
  • [IJ plugin] v3 -> v4 migration: enum capitalization (#5128)
  • [ast] Initial CCN support (#5118)
  • [infra] Make generateSourcesDuringGradleSync opt-in now that we have the IJ plugin (#5117)
  • [compose] Catch ApolloException in toState and watchAsState (#5116)
  • [IJ plugin] v3 -> v4 migration: Gradle conf (#5114)
  • [compiler] validate query/mutation/subscription directives (#5113)
  • [cache] Move serialization outside of cache lock (#5101)
  • [infra] Use compose 1.5.0 stable (#5108)
  • [compiler] Fix "no schema found" error message (#5106)
  • [IJ plugin] v3 -> v4 migration: deprecations/renames, part 2 (#5109)
  • [infra] More Apollo AST APIs (#5104)
  • [infra] Apollo AST: add start/end instead of endColumn/endLine (#5103)
  • [IJ plugin] v3 -> v4 migration: deprecations/renames (#5099)
  • [ast] fix column computation of block strings (#5102)
  • [benchmarks] Add macrobenchmarks (#5100)
  • [IJ plugin] Migrate to Apollo Kotlin 4: dependencies (#5097)
  • [IJ plugin] Support IJ platform 232 (#5095)
  • [infra] bump ijgp (#5091)
  • [infra] remove a bunch of build workarounds (#5090)
  • [4.0 cleanups] Remove DefaultImpls everywhere (#5088)
  • [infra] Remove golatac (#5086)
  • [infra] Use SQLDelight 2.0.0-rc02 and AGP 8.0.0 (#5085)
  • [ast] Switch back the parser to Strings and add more tests (#5078)
  • [benchmarks] add graphql-java benchmark (#5077)
  • [infra] Use Kotlin 1.9.0 (#4997)
  • [ast] Turn into a mpp module and move jmh benchmark to an integration test (#5072)
  • [IJ/AS Plugin] Add unused operation and unused field inspections (#5069)
  • [ast] add endLine/endColumn (#5064)
  • [ast] Add more tests and rewrite the lexer to use bytes instead of strings (#5063)
  • [IJ plugin] Add a test for ApolloFieldInsightsInspection (#5062)
  • [IJ plugin] Add an "enclose in @defer fragment" quick fix for slow field inspection (#5061)
  • [IJ plugin] Add "Schema in .graphql file" inspection (#5059)
  • [ast] Add multiplatform apollo-ast (#5047)
  • [IJ plugin] Distinguish Apollo v3 and v4 (#5056)
Jun 30, 2023

A new alpha with updates to the IntelliJ/Android Studio plugin and better JS interop.

🧩Navigate to GraphQL

You can now navigate from Kotlin both GraphQL or Generated code:

https://github.com/apollographql/apollo-kotlin/assets/3974977/acd4bf34-db35-4442-a7af-b6151701620c

See blog the blog post and installation instructions for more information.

🧩Field insights

You can now connect the IJ/AS plugin to your GraphOS account. If your backend is configured to report field traces, the plugin will display a warning for expensive fields that may be slow to fetch.

You can configure it in your IJ/AS settings Languages & Frameworks -> GraphQL -> Apollo Kotlin. See also #5048 for a video of the setup.

🌐@jsExport

responseBased codegen can now generate models annotated with @jsExport. This allows to fetch your response using faster JS-only APIs and cast them to the generated models. See the JS interoperability documentation for more information. Many thanks to @baconz for the deep dive 💙

👷‍ All changes

  • [IJ plugin] FieldInsights (#5034)
  • [IJ plugin] Keep navigation working when using import aliases for operations and fragments (#5041)
  • [IJ plugin] Make navigation more robust when gql elements are lowercase (#5037)
  • Refactor custom scalar adapters (#4905)
  • [IJ plugin] Add an 'Open in Apollo Sandbox' action (#5022)
  • [IJ plugin] Update v3 version and codegen wording (#5015)
  • add encodeDefaults to introspection schema serializer (#5016)
  • Better error message for Kotlin objects that cannot be converted to JSON (#5011)
  • Http cache: do not cache mutations (#5014)
  • [IJ plugin] Find usages GQL -> Kotlin (#5006)
  • [IJ plugin] Add GQL -> generated Kotlin navigation (#4999)
  • [IJ plugin] Override GraphQL icons (#4980)
  • add Service.operationManifestFormat (#4981)
  • [WebSockets] Fix fan out in websocket network transport (#4972)
  • Throw inside flow in MapTestNetworkTransport (#4982)
  • [IJ plugin] Add navigation to type declaration (cmd shift b) (#4978)
  • [IJ plugin] Add navigation to input types / fields (#4968)
  • Fix jsExport Gradle annotation mismatch (#4975)
  • Generate response based code with jsExport (#4907)
  • [IJ plugin] Navigate to enum declaration (#4965)
  • remove Built-By attribute in generated jars (#4961)
May 25, 2023

A maintenance release with bugfixes, mostly around WebSockets and subscriptions as well as a LocalTime adapter and options to work with operation manifests.

Huge THANK YOU to @baconz, @AlexHartford, @Oleur for the love they put in WebSocket contributions as well as @Jephuff for their first contribution 💙 .

👷‍ All changes

  • add Service.operationManifestFormat (#4981)
  • WebSockets: Fix fan out in websocket network transport (#4972)
  • Test: Throw inside flow in MapTestNetworkTransport (#4982)
  • Doc: Add Optional.Absent in documentation (#4979)
  • Doc: clarify that operationBased codegen is the recommendation (#4966)
  • AST: use existing as the base for copying enum values (#4943)
  • Cache: Fix deleting records in the SqlNormalizedCache with cascade-true (#4938)
  • Compiler: Fix deprecated input field usage false positive (#4935)
  • Doc: Clarify KDoc of watch() (#4914)
  • WebSockets: allow changing the serverUrl of WebSocketNetworkTransport (#4885)
  • WebSockets: accept connectionPayload lambda instead of static auth (#4855)
  • Add LocalTime adapter for Java and Kotlin (#4829)
  • Doc: Add a section about the operationBased codegen (3.x) (#4940)
May 16, 2023

This release is the first alpha of the next major version of Apollo Kotlin: 4.0.0.

This version is under development, but we want to give you a preview of what's coming, and get your early feedback. Please see the roadmap for more details about the release plan.

While version 3 changed a lot of APIs compared to version 2, version 4 should be mostly compatible with version 3. Version 4 will even keep the same package name in order to keep the number of changes low.

The error handling has changed but besides that, the version should be mostly compatible. Please consult the migration guide for all the details.

We would love to hear your feedback on this release. Please report any issues, questions, ideas, or comments on the issue tracker.

🛠️ Android Studio / IntelliJ plugin

See this page for installation instructions and more information.

This plugin for Android Studio and IntelliJ helps you work with Apollo Kotlin. It provides the following features:

  • Automatic code generation
  • Integration with the GraphQL IntelliJ Plugin
  • Navigation to GraphQL definitions
  • Helpers to migrate your project to the latest version

⚡️ ApolloResponse.exception for error handling

Error handling is an important aspect of a client library and we found it could benefit from some changes.

In particular we are moving away from throwing exceptions:

  • This improves dealing with Flows as they will no longer terminate on errors
  • It helps grouping all error handling (network, GraphQL, caching) in the same area of your code

To that effect, there is now an ApolloResponse.exception : ApolloException property, which will be present when a network error or cache miss have occurred, or when GraphQL errors are present:

val data = response.data
when {
  data != null -> {
    println("The server returned data: $data")
  }
  else -> {
    // An error happened, check response.exception for more details or just display a generic error 
    when (response.exception) {
      is ApolloGraphQLException -> // do something with exception.errors
      is ApolloHttpException -> // do something with exception.statusCode
      is ApolloNetworkException -> TODO()
      is ApolloParseException -> TODO()
      else -> // generic error
    }
  }
}

To ease the migration to v4, the v3 behavior can be restored by calling ApolloClient.Builder.useV3ExceptionHandling(true).

Feedback about this change is welcome on issue 4711.

☕️ apollo-runtime-java for better Java support

As v3 has a Kotlin and Coroutines first API, using it from Java is sometimes impractical or not idiomatic. That is why in v4 we are introducing a new Java runtime, written in Java, which provides a Java friendly API. It is callback based and doesn't depend on a third-party library like Rx.

To use it in your project, instead of the usual runtime (com.apollographql.apollo3:apollo-runtime), use the following dependency in your build.gradle[.kts] file:

implementation("com.apollographql.apollo3:apollo-runtime-java")

Then you can use the ApolloClient class from Java:

ApolloClient apolloClient = new ApolloClient.Builder()
  .serverUrl("https://...")
  .build();

apolloClient
  .query(MyQuery.builder().build())
  .enqueue(new ApolloCallback<MyQuery.Data>() {
      @Override public void onResponse(@NotNull ApolloResponse<MyQuery.Data> response) {
        System.out.prinitln(response.getData());
      }
  });

A few examples can be found in the tests.

🔃 Multi-module: automatic detection of used types

In multi-module projects, by default, all the types of an upstream module are generated because there is no way to know in advance what types are going to be used by downstream modules. For large projects this can lead to a lot of unused code and an increased build time.

To avoid this, in v3 you could manually specify which types to generate by using alwaysGenerateTypesMatching. In v4 this can now be computed automatically by detecting which types are used by the downstream modules.

To enable this, add the "opposite" link of dependencies with isADependencyOf().

// schema/build.gradle.kts
apollo {
  service("service") {
    packageName.set("schema")

    // Enable generation of metadata for use by downstream modules 
    generateApolloMetadata.set(true)

    // More options...

    // Get used types from the downstream module
    isADependencyOf(project(":feature1"))

    // You can have several downstream modules
    isADependencyOf(project(":feature2"))
  }
}
// feature1/build.gradle.kts
apollo {
  service("service") {
    packageName.set("feature1")
    
    // Get the generated schema types (and fragments) from the upstream schema module 
    dependsOn(project(":schema")) 
  }
}
Apr 21, 2023

This patch release contains 2 bug fixes.

👷‍ All changes

  • Add ignoreApolloClientHttpHeaders (#4838)
  • Download introspection: handle GraphQL errors (#4861)
Apr 3, 2023

This release adds two new artifacts that contain Jetpack compose extensions amongst other fixes.

💙️ External contributors

Many thanks to @slinstacart and @hbmartin for their contributions to this release!

✨ [New] Jetpack compose extension (#4802)

You can now use the apollo-compose-support artifact:

// build.gradle.kts
dependencies {
  implementation("com.apollographql.apollo3:apollo-compose-support")
}

This artifact contains the toState() and watchAsState() extensions:

/**
 * A stateful composable that retrieves your data
 */
@OptIn(ApolloExperimental::class)
@Composable
fun LaunchDetails(launchId: String) {
    val response by apolloClient.query(LaunchDetailsQuery(launchId)).toState()
    val r = response
    when {
        r == null -> Loading() // no response yet
        r.exception != null -> ErrorMessage("Oh no... A network error happened: ${r.exception!!.message}")
        r.hasErrors() -> ErrorMessage("Oh no... A GraphQL error happened ${r.errors[0].message}.")
        else -> LaunchDetails(r.data!!, navigateToLogin)
    }
}

/**
 * A stateless composable that displays your data
 */
@Composable
private fun LaunchDetails(
        data: LaunchDetailsQuery.Data,
) {
  // Your UI code goes here
}

If you are working with paginated data, you can also add apollo-compose-paging-support to your dependencies:

// build.gradle.kts
dependencies {
  implementation("com.apollographql.apollo3:apollo-compose-paging-support")
}

This artifact contains a helper function to create androidx.pagin.Pager instances (androix documentation):

@OptIn(ApolloExperimental::class)
@Composable
fun LaunchList(onLaunchClick: (launchId: String) -> Unit) {
  val lazyPagingItems = rememberAndCollectPager<LaunchListQuery.Data, LaunchListQuery.Launch>(
          config = PagingConfig(pageSize = 10),
          appendCall = { response, loadSize ->
            if (response?.data?.launches?.hasMore == false) {
              // No more pages
              null
            } else {
              // Compute the next call from the current response
              apolloClient.query(
                      LaunchListQuery(
                              cursor = Optional.present(response?.data?.launches?.cursor),
                              pageSize = Optional.present(loadSize)
                      )
              )
            }
          },
          getItems = { response ->
            // Compute the items to be added to the page from the current response
            if (response.hasErrors()) {
              Result.failure(ApolloException(response.errors!![0].message))
            } else {
              Result.success(response.data!!.launches.launches.filterNotNull())
            }
          },
  )
  
  // Use your paging items:
  if (lazyPagingItems.loadState.refresh is LoadState.Loading) {
    Loading()
  } else {
    LazyColumn {
      items(lazyPagingItems) { launch ->
        // Your UI code goes here
      }
      item {
        when (val append = lazyPagingItems.loadState.append) {
          is LoadState.Error -> // Add error indicator here 
          LoadState.Loading -> // Add loading indicator here
        }
      }
    }
  }
}

As always, feedback is very welcome. Let us know what you think of the feature by either opening an issue on our GitHub repo , joining the community or stopping by our channel in the KotlinLang Slack(get your invite here).

✨ [New] Gradle plugin: run codegen after gradle sync

If you import a new project or run a Gradle sync, your GraphQL models are now automatically generated so that the IDE can find the symbols and your files do not show red underlines. This takes into account Gradle up-to-date checks and it should be pretty fast. If you want to opt-out, you can do so with generateSourcesDuringGradleSync.set(false):

apollo {
  // Enable automatic generation of models during Gradle sync (default)
  generateSourcesDuringGradleSync.set(true)

  // Or disable automatic generation of models to save on your Gradle sync times
  generateSourcesDuringGradleSync.set(false)

  service("api") {
    // Your  GraphQL configuration
  }
}

👷‍ All changes

  • Allow to add HTTP headers on top of ApolloClient ones (#4754)
  • Kotlin 1.8 (#4776)
  • Move cache creation outside the main thread (#4781)
  • Cache: ignore hardcoded @include(if: false) directives (#4795)
  • Add % to reserved characters to encode in URL (#4804)
  • First drop of experimental Compose support libraries (#4783)
  • Consider variable default values with @skip/@include/@defer (#4785)
  • Gradle plugin: run codegen after gradle sync (#4796)
  • Allow custom SqlDriver (#4806)
  • Multipart subscriptions (#4768, #4807, #4738)
  • GQLNode.print for type extensions (#4814)
Latest
v5.0.0-alpha.7
Tracking Since
Jun 11, 2020
Last fetched Apr 19, 2026