2024-11-04
Version 4.1.0 updates usages of Ktor from 2.3.11 to 3.0.0:
- If you are using
apollo-runtime-js
orapollo-debug-server-jvm
, you need to update your app to Ktor 3.0.0+ at the same time as updating to Apollo 4.1.0 (apollo-debug-server-android
is unaffected). - If you are using the deprecated
apollo-mockserver
orapollo-ktor-support
from this repo, you need to update to the new coordinates.
All other cases are unaffected. In particular, apollo-runtime
on Android and iOS uses OkHttp and NsUrlConnection respectively and is not impacted by the Ktor update.
You can read more details in the pull request.
application/graphql-response+json
is a new media type being introduced by the GraphQL over HTTP draft. It allows differentiating a valid GraphQL response from an error JSON response that could be transmitted by a cache or proxy in the HTTP chain.
If your server uses application/graphql-response+json
and returns non-2xx response, Apollo Kotlin will now parse those responses and expose data
and errors
instead of returning an ApolloHttpException
before.
If you need to access the status code, you can do so using executionContext[HttpInfo]
. For an example, you can restore the throwing behaviour with the following interceptor:
object : ApolloInterceptor {
override fun <D : Operation.Data> intercept(
request: ApolloRequest<D>,
chain: ApolloInterceptorChain,
): Flow<ApolloResponse<D>> {
return chain.proceed(request).onEach {
val httpInfo = it.executionContext[HttpInfo]
if (httpInfo != null && httpInfo.statusCode !in 200..299) {
throw ApolloHttpException(httpInfo.statusCode, httpInfo.headers, null, "HTTP request failed")
}
}
}
}
The IntelliJ plugin is now compatible with K2 (#6150)
- [all] Update kotlinpoet to 2.0.0 (#6215)
- [all] Update to Ktor 3 (#6214)
- [all] Remove
apollo-mockserver
andapollo-ktor-support
(#6215) - [all] Remove mockserver as a dependency of apollo-testing-support (#6218)
- [ast] Do not escape slashes in single quoted strings (#6190)
- [runtime] Add support for application/graphql-response+json (#6170)
- [runtime] Do not call experimental webSocket() method re-entrently (#6197)
- [debug server] Remove Ktor dependency from apollo-debug-server JVM (#6224)
- [codegen] Do not add internal to private members (#6213)
- [codegen] Fix name clash in data builder names when two types differ only by their case (#6195)
- [gradle plugin] Allow null in KSP arguments for Apollo Compiler Plugins (#6200)
- [gradle plugin] Do not log the full introspection JSON (#6199)
- [gradle plugin] Deprecate TargetLanguage.KOTLIN_1_5 (#6193)
- [IJ Plugin] Make the cache viewer understand the blob db format (#6187)
- [IJ Plugin] Bump IJ Platform Gradle Plugin to 2.0.1 (#6185)
- [IJ Plugin] Migrate to the K2 compatible Analysis API (#6150)
- [IJ Plugin] Schedule the GraphQL configuration reload early (#6228)
- [IJ Plugin] Rename related generated code when renaming an Operation/Fragment (#6227)
- [IJ Plugin] Only highlight the name of unused operations, rather than the whole operation (#6226)
2024-10-01
This release contains a handful of bug fixes and improvements.
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
}
}
}
}
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")
Many thanks to @ebrattli, @agrosner and @cvb941 for their contributions to this release 💙!
- [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
inMapJsonReader
(#6141) - [cache] Allow to store
JsonNumber
inRecord
(#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)
2024-07-29
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'll need to replace all the com.apollographql.apollo3
with com.apollographql.apollo
in your codebase.
- Migration guide: https://www.apollographql.com/docs/kotlin/v4/migration/4.0.
- Evolution policy: https://www.apollographql.com/docs/kotlin/v4/essentials/evolution.
- Blog post: coming soon.
Thanks again to everyone who provided feedback during the alphas/betas.
- New package name (migration guide)
- Moved artifacts (Apollo Kotlin galaxy documentation page)
- Improved error handling (migration guide)
- Android Studio/IntelliJ Plugin (installation instructions)
- Multiplatform GraphQL parser (doc)
- Apollo Compiler Plugin API (doc)
- WasmJs support
- NetworkMonitor API (doc)
- Experimental WebSocket API (doc)
- Experimental support for
@oneOf
(GraphQL RFC) - Experimental support for
@semanticNonNull
and@catch
(doc)
- #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
2024-07-22
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.
.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)
2024-07-10
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)
2024-07-08
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
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.
- [BREAKING][all] Change package name to
com.apollographql.apollo
- [BREAKING][all] Remove incubating compose support (#5987)
- [BREAKING][all] Remove apollo-cli (#5986)
- [BREAKING][all] Remove incubating normalized cache (#5985)
- [BREAKING][all] Nullability: Move 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 (#6012)
- [🐘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 ofgradle-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)
- [mockserver] Deprecate com.apollographql.apollo3.mockserver.MockServer (#5943)
2024-06-05
#5931: This version is built with K2. You will need Kotlin 1.9+ on the JVM to build 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.
- [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)