Skip to content

Conversation

@ssestak
Copy link
Contributor

@ssestak ssestak commented Jan 14, 2026

This PR upgrades apollo-ios to version 2.0, modernizing the API to use async/await and improving the overall architecture. The adapter initialization is now handled by a dedicated GraphQLAPIConfiguration struct, and completion handlers have been replaced with throwing async functions. The interceptor system has been updated to align with the new standards in Apollo 2.0.

Key Features

  • Upgraded Apollo iOS: The core dependency apollo-ios has been updated from version 1.17.0 to 2.0.4.
  • Async/Await API: The GraphQLAPIAdapter now uses async/await for fetch and perform methods, replacing the previous completion handler-based approach.
  • Configuration Structs:
    • GraphQLAPIConfiguration has been introduced to provide a cleaner and more robust way to configure the adapter.
    • GraphQLRequestConfiguration allows for per-request customizations, such as adding extra headers.
  • Updated Interceptor Chain: The interceptor implementation has been refactored to conform to the new InterceptorProvider architecture in Apollo iOS 2.0.
  • Improved Error Handling: Error mapping has been enhanced to correctly handle URLError and CancellationError, providing more specific error types like .connection and .cancelled.
  • Dependency Cleanup: The SQLite.swift dependency, which is no longer required by Apollo 2.0, has been removed.

API Migration

Feature Before (Apollo 1.x) After (Apollo 2.x)
Initialization GraphQLAPIAdapter(url: ...) let config = GraphQLAPIConfiguration(url: ...)
GraphQLAPIAdapter(configuration: config)
Fetch Query adapter.fetch(query: q) { result in ... } let data = try await adapter.fetch(query: q)
Perform Mutation adapter.perform(mutation: m) { result in ... } let data = try await adapter.perform(mutation: m)
Request Headers RequestHeaders protocol used as a context object. GraphQLRequestConfiguration struct passed to methods.

Šimon Šesták and others added 4 commits January 14, 2026 14:50
BREAKING CHANGE: Public API now uses native async/await instead of callbacks.

- Update Apollo dependency from 1.17.0 to 2.0.4
- Rewrite interceptors for new Apollo 2.0 architecture
- Replace callback-based API with async throws
- Add NoCacheInterceptor for explicit cache-less operation
- Remove ObserverContextStore (single interceptor pattern)
- Add Sendable conformance to error types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…uests

Introduce `GraphQLAPIConfiguration` and `GraphQLRequestConfiguration` structs to simplify and centralize the configuration for the `GraphQLAPIAdapter` and individual GraphQL requests.
The `README.md` has been updated to reflect the new Apollo iOS dependency version and the updated usage of `GraphQLAPIAdapter` which now requires a configuration object and uses `async throws` for fetch and perform operations.
Corrected `swiftPackageManager` to `swiftPackage` in configuration example and fixed typo in Xcode build phase script instructions. Updated the `apollo-ios-cli` binary.
@ssestak ssestak requested review from jmarek41 and samoilyk January 14, 2026 19:59
public let defaultHeaders: [String: String]

/// Network observers for monitoring requests (logging, analytics, etc.).
public let networkObservers: [any GraphQLNetworkObserver]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nakonec ses rozhodl neimplementovat tu zmenu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V predchádzajúcej verzii to je naimplementované ale skrz to že som pridal teraz "abstrakciu" skrz pomocné štruktúry na konfiguráciu aby sme mohli do budúcna jednoduchšie rozširovať konštruktor alebo pridať support napríklad additional parametrov vrámci volaní. Tak variadické generiká stratili význam nakoľko nemáme ešte možnosť (minimálne o nej neviem) ako uložiť heterogénne pole 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants