- Ability to set the journal mode on sqlite cache databases (#3399): There is now a function to set the journal mode of the connected sqlite database and control how the journal file is stored and processed. See PR #443. Thanks to @pixelmatrix for the feature request.
- Fix crash when
GraphQLError
is “too many validation errors”" (#438): When a GraphQLError from the JS parsing step is a “Too many validation errors” error, there is nosource
in the error object. Codegen will now check for it to avoid this edge case crash. - Cache write interceptor should gracefully handle missing cache records (#439): The work to support the
@defer
directive introduced a bug where the cache write interceptor would throw if no cache records were returned during response parsing. This is incorrect as there are no cache records in the case of anerrors
only GraphQL response. - Avoid using
fatalError
onJSONEncodable
(#128): The fatal error logic inJSONEncodable
was replaced with a type constraintwhere
clause. Thank you to @arnauddorgans for the contribution. - Introspection-based schema download creates duplicate
@defer
directive definition (#3417): The codegen engine can now correctly detect pre-existing@defer
directive definitions in introspection sources and prevent the duplicate definition. See PR #440. Thanks to @loganblevins for reporting the issue.
- Experimental support for the
@defer
directive: You can now use the@defer
directive in your operations and code generation will generate models that support asynchronously receiving the deferred selection sets. There is a helpful property wrapper with a projected value to determine the state of the deferred selection set, and support for cache reads and writes. This feature is enabled by default but is considered experimental. Please refer to the documentation for further details. - Add
debugDescription
toSelectionSet
(#3374): This adds the ability to easily print code generated models to the Xcode debugger console. See PR #412. Thanks to @raymondk-nf for raising the issue. - Xcode 16 editor config files (#3404): Xcode 16 introduced support for
.editorconfig
files that represent settings like spaces vs. tabs, how many spaces per tab, etc. We've added a.editorconfig
file with the projects preferred settings, so that the editor will use them automatically. See PR #419. Thanks to @TizianoCoroneo for raising the issue.
- Local cache mutation build error in Swift 6 (#3398): Mutating a property of a fragment annotated with the
@apollo_client_ios_localCacheMutation
directive caused a compile time error in Xcode 16 with Swift 6. See PR #417. Thanks to @martin-muller for raising the issue.
- Added
ExistentialAny
requirement (#379): This adds the-enable-upcoming-feature ExistentialAny
to all targets to ensure compatibility with the upcoming Swift feature. - Schema type renaming (#388): This adds the feature to allow customizing the names of schema types in Swift generated code.
- JSONConverter helper (#380): This adds a new helper class for handling JSON conversion of data including the ability to convert
SelectionSet
instances to JSON.
- ApolloSQLite build error with Xcode 16 (#386): This fixes a naming conflict with Foundation in iOS 18 and the SQLite library. Thanks to @rastersize for the contributon.
- Rebuilt the CLI binary with the correct version number: The CLI binary included in the
1.12.1
package was built with an incorrect version number causing a version mismatch when attempting to execute code generation.
- Rebuilt the CLI binary: The CLI binary included in the
1.12.0
package was built with inconsistent SDK versions resulting in the linker signing not working correctly.
ID
as a custom scalar (#3379): This changes the generation of the built-in GraphQLID
scalar to be treated as a custom scalar that can be modified by the user. See PR #363.
- Adds visionOS deployment to ApolloTestSupport podspec (#364): This adds the
visionOS
deployment target to the ApolloTestSupport podspec to match the other package managers. - Add
@_spi(Execution)
to executor for import in test mocks (#362): This replaces the use of@testable
in ApolloTestSupport with specific@_spi
scopes. This resolves a few issues that have been reported where the Apollo module could not be built for testing in non-debug configurations.
- Added
refetchOnFailedUpdates
option toGraphQLQueryWatcher
(#347): This allows you to configure the query watcher not to refetch it's query from the server when a cache read to update it's data fails.
-
Generated input objects have default
nil
value for parameters with a schema-defined default value (#2997): When the schema defines a default value for an input parameter, you can now omit that parameter when initializing the input object and the default value will be used. This corrects feature parity with the Apollo Kotlin client. See PR #358. -
Fix namespacing error in
InterfaceTemplate
(#3375): This fixes an issue where having a schema type namedInterface
caused compilation errors in generated code. See PR #359.
- Added support for visionOS (#3320): All the dependecies that Apollo iOS requires have been updated to add support for visionOS, so we can now add official support for visionOS too. See PR #333.
- Add Sendable conformance to some basic SchemaTypes: This adds
Sendable
conformance to the some of the generated schema types. This does not mean that all of the generated code is safe to use yet with complete concurrency checking of Swift 5.10 but it gets us closer to that goal. See PR #322. Thanks to @bdbergeron for the contributon.
- Fix injecting of context for UploadRequest: Any request context passed into an upload request was not being added to the HTTP request and would not be available to the interceptor chain. See PR (#302). Thanks to @RobertDresler for the contribution.
- Added support for SPM Package.resolved format version 3 (#3355): When using Xcode 15.3 the codegen CLI would fail the
generate
command with an error stating the Package.resolve file version is unsupported. Version 3 is now accepted as a valid file format for the codegen version checker. See PR (#304). - PrivacyInfo.xcprivacy file is invalid for Apollo and ApolloApi (#3359): We received reports that when submitting to the App Store the submission would fail with an error stating that the privacy manifests were invalid. We identified the error and updated the privacy files. See PR (#309). Thanks to @azilbershtein for raising the issue.
- Provide a direct means to observe changes in ApolloStore:
ApolloStore
now exposes it's subscriber mechanism publicly. This means you can now observe and receive notifications about changes to the store. See PR (#300). Thanks to @jamesonwilliams for the contribution. - Remove redundant iteration in EntitySelectionTree merging algorithm: The conditions for merging selections were revisited and we identified, and removed, a redundant iteration. This is a significant performance improvement as it removes an entire additional iteration through all the conditional scopes in the tree. See PR (#308).
- Backwards Compatibility issues in 1.9.1: 1.9.1 introduced a minor breaking change for some users who were creating a custom implementaiton of
ApolloClientProtocol
. Sorry about that! This patch release fixed the compatiblity. See PR #290. Thanks to @michaelloo for raising the issue.
- Session and task descriptions parameters added to
URLSessionClient
(#286): TheURLSessionClient
now allows you to set asessionDescription
on the session andtaskDescription
on each task. These are helpful when debugging, especially when analyzing HTTP traffic with Instruments. Thanks to @hishma for the contribution.
SelectionSet
generated initializers don't compile withself
parameter (#3330): Selection set initializers now use a local property name when the external property name is a Swift reserved word; see PR #257. Thanks to @grantjbutler for raising the issue.- asXXXXXXX property on a union never returning
nil
if selection set empty (#3326): - The codegen logic to determine whether a selection set is composite or not has been improved to handle the case when__typename
was the only field in the selection set; see PR #261. Thanks to @vincentisambart for raising the issue.
- Feature/ContextIdentifier for the mutate queries (#281): Mutation operations can now be given a context identifier to be used later in the request. Thanks to @VladimirK-ah for the contribution.
- New import directive for operations: GraphQL operations now support a directive to control custom module import statements in the generated file. Any operation that includes the directive
@import(module:)
, on the defintion line, with a suppliedString
as the module name will have that module used in a Swiftimport
statement at the top of the operation file and any referenced fragments. Thank you to @hemel for the contribution (#236 / #245).
- The
fragmentDefinition
remains in all generated fragments whenoperationDocumentFormat
does not include.definition
(#3282): Code generation will now only generate definitions in fragment files if theoperationDocumentFormat
config contains the.definition
value (#218). Thank you to @jimisaacs for raising the issue. - Custom scalar file header comment (#3323): The header comment for generated custom scalar files was incorrectly changed to state that the output "should not be edited" but the file content could still be edited and would not be overwritten. The header comment has been changed back to state that the contents will be preserved during subsequent codegen executions. Thank you to @matsudamper for raising the issue and the contribution to fix it (#243).
- WebSocket disconnection errors are no longer printed to stdout (#3325): See PR (#253) Thank you to @sgade for raising the issue.
- Duplicate
@defer
directive error (#235): When executing codegen against Apollo Router and a schema that supports the@defer
directive it would fail with an error stating the directive is duplicated.
- Added `InputObject`` casing strategy (#137): We've added a new casing strategy option for InputObjects which mimics the behaviour of the enum case conversion strategy. Thank you to @alexifrim for raising this in issue #3257.
- Added
GraphQLResult
conversion extension (#139):GraphQLResult
response data can now be easily converted into a JSON dictionary. This is useful for taking server response data and serializing it into a JSON dictionary which can then be used in a test suite. - Codegen performance improvements (#152): There has been a bunch of refactoring work to prepare for future codegen features but we've also managed to squeeze out some performance improvements.
- Fixed inconsistent ordering of fragments in generated operation definitions (#130): In order to make the ordering of fragments consistent, they are now alphabetized. This is a change to the data that gets sent over the wire when making a network request for an operation with fragments. Persisted Queries users should re-register their queries when upgrading to this version. Thank you to @scottasoutherland for reporting the issue.
- Add initializer for
SelectionSet
that takes a[String: Any]
JSON object (#102): Thank you to @Cookiezby for the contribution.
ApolloCodegenLib
Now Uses Swift Concurrency
To improve the performance of the code generation, the ApolloCodegenLib
now uses async/await
. Code generation is now parallelized and should complete much faster for users with a large number of GraphQL files.
This means that the entry point function, ApolloCodegen.build(with configuration:)
is now an async
function. For users using the ApolloCodegenLib
directly, you will need to make your call sites into this function use async/await
. In most cases, this requires minimal code changes. Please see the 1.7.0 migration guide for information on how to upgrade.
See PR #57.
- Fixed a bug with ApolloAPI.Object clashing with custom objects name Object (#94): Thank you to 215eight for reporting the issue.
- Fix bug with AnyHashable coercion (#68): This is an additional fix for the crashes on iOS 14.4.1.
The Apollo iOS ecosystem is changing in the 1.6.0 release in order to provide a better development experience for users. For most users nothing will change, while some users will see a minor difference. The biggest change is that the ApolloCodegenLib
is now in a separate repo/package that will need to be included as its own dependency from apollo-ios-codegen if you are doing your code generation through Swift. If you are using the codegen CLI then no changes are necessary.
For a detailed breakdown of the changes please see this GitHub Issue.
- Fixed crashes in iOS 14.4 and below (#61): Thank you to matijakregarGH for reporting the issue.
The purpose of this release is to provide a deprecation message to users of ApolloCodegenLib
who are scripting their code generation in advance of an upcoming change to our libraries and repo structure. Beginning with the upcoming 1.6.0 release the code generation libraries will be their own SPM package in their own repo which will require you to add a new dependency to you project in order for your code generation scripting to compile. More information can be found in our announcement of this change.
If you would like to avoid this deprecation warning in your builds feel free to stay on 1.5.1 or earlier, this warning will be gone in the 1.6.0 release
PR containing deprecation warning for reference: #3243.
- Added
OutputOptions
property to codegen for marking generated classes asfinal
(#3189): Thank you to @Mordil for the contribution.
- Codegen
itemsToGenerate
option for.all
not generating an operation manifest (#3215): Thank you to @TizianoCoroneo for finding and fixing the issue. - Codegen operation manifest inadvertantly being generated twice (#3225): Thank you to @jimisaacs for finding and fixing the issue.
- Added the ability pass a custom
RequestContext
to networking APIs (#3198): Thank you to @danieltiger for the contribution.- Minor Breaking Change: The
requestContext
parameter is optional with a default value ofnil
. This means there are no breaking changes to the APIs for making networking calls. However, therequestContext
parameter was also added to theApolloClientProtocol
. For custom implementations of this protocol (usually used for unit testing), you will need to add therequestContext
parameter to your function signatures.
- Minor Breaking Change: The
- Null values are no longer stripped from the underlying data used by generated
SelectionSet
models (apollo-ios-dev/#25):- When these models were manually inserted into the cache, the null fields, which were stripped, were not written to the cache. This caused unintended cache misses when fetching those values back out of the cache.
- This fixes #3092. Thank you to @ aleksanderlorenc-lw for raising this issue.
- Added the ability to set a casing strategy for field names in code generation (#2738): See PR (#3171). Thank you to @Spatel91111 for the feature request.
- Updated the way persisted queries are configured for code and manifest generation: See PR (#3175)
- Updated docs for
other
schema module type to provide more clarity (#3164): See PR (#3170) Thank you to @Mordil for suggesting this update.
- Fix two issues with generated models: See PR (#3168). Thank you to @iAmericanBoy for finding these issues and providing a reproduction case.
- Fix computation of operation identifiers for persisted queries: See PR (#3163). Thank you to @WolframPRO for finding these issues.
- Throw an error when an invalid key is present in the codegen configuration JSON (#2942): See PR (#3125) Thank you to @Iron-Ham for the contribution.
- Cleanup unused imports and declarations. (#3099): See PR (#3100) Thank you to @Iron-Ham for raising the issue and contributing the fix.
- Improvement to response code error API (#2426): See PR (#3123). Thank you to @dfperry5 for the contribution.
- Improved file path support for operation manifest generation: See PR (#3128)
- Fix two issues in test mock generation: See PR (#3120). Thank you to @TizianoCoroneo for finding this issue and contributing the fix.
- Fixed precondition failure when surpassing graphql-js max error count (#3126): See PR (#3132).
- Deprecated
queryStringLiteralFormat
inApolloCodegenConfiguration
: Query string literals will now always be generated as single line strings. See PR (#3129).
- Fix crashes in test mocks when setting an array of union types (#3023): See PR (#3089). Thank you to @jabeattie & @scottasoutherland for raising the issue.
- Deprecated
APQConfig
&operationIdentifiersPath
inApolloCodegenConfiguration
: These have been replaced withOperationDocumentFormat
andOperationManifestFileOutput
respectively. Please see the documentation forApolloCodegenConfiguration
for more information.
Though 1.3.0
is a minor version bump, some critical issues were addressed in this version that requires a small breaking change during the upgrade. While we strive to make the upgrade path for minor versions seamless, these issues could not be reasonably resolved without requiring this migration.
For a detailed explanation of the breaking changes and a guide on how to migrate to 1.3.0
, see our migration guide.
- Using reserved keyword
Type
as in selection fields does not compile (#3006): See PR #3058. Thank you to @Nielssg for raising the issue. - Memory leak from
InterceptorRequestChain
when ending the chain withreturnValueAsync
(#3057): See PR #3070. Thank you to @marksvend for raising the issue.
- Support SOCKS proxies for debugging websocket based subscriptions(#2788): Thank you to @tahirmit for the contribution.
- Fix conversion of generated models into nested type cases (#2989 & #2980): In some cases, the generated models were missing types when calculating which fragments were fulfilled for a selection set. This was causing type case conversion to return
nil
incorrectly. See PR #3067. Thank you to @tgyhlsb and @dafurman for raising these issues. - Fix crashes in code generation when merging fragments at definition root (#3071): When fragments with type conditions were defined on the root of an operation or named fragment, the code generation engine was crashing. See PR #3073. Thank you to @tahirmit for raising and helping us reproduce this issue.
- Fix parsing of input objects as default values for input params (#2978): The codegen engine will no longer crash in this situation. Thank you to @ecunha-ta for raising the issue.
- Added new validation to alert users to type naming conflict when running code generation(#2405): See PR #3041.
- Int values failing to cast to Scalar Type during cache key resolution (#3034): See PR #3037. Thank you to @asbhat for raising the issue.
- Fix malformed RootEntityType on generated fragment with
@include
condition. (#2962): See PR #3045. Thank you to @alexisbronchart for raising the issue.
Though 1.2 is a minor version bump, a critical problem was addressed in this version that requires a small breaking change during the upgrade. While we strive to make the upgrade path for minor versions seamless, this issue could not be reasonably resolved without requiring this migration.
For most users, this migration will only require a single change to your SchemaConfiguration.swift
file.
For a detailed explanation of the breaking changes and a guide on how to migrate to v1.2, see our migration guide.
- Cache Key Configuration API Changes (#2990): The API for configuring custom cache keys has had a minor change in this version. The signature of the
cacheKeyInfo(for:object:)
function, defined in your generated SchemaConfiguration.swift file, has been modified. For more information, see our migration guide.
- Improved performance of GraphQL execution (#2990): Improvements to the
GraphQLExecutor
resulted in a ~15-20% reduction in execution time for parsing and mapping network response or cache data onto generated models. - Improved performance of generated model initialization and type conversions (#2990): The
DataDict
used to store the data for generated models has been updated to use copy-on-write value semantics. This resulted in a ~70-80% reduction in the execution time of initialization and type case conversions in the generated models.
- Pruning generated files for
.relative(subpath:)
operations (#2969): See PR #2994. Thank you to @jimisaacs for raising the issue. - InputObjects generated with incorrect getter/setter key (#2858): See PR #2996. Thank you to @Austinpayne for raising the issue.
- Generates conflicting types for fields of singular and plural names (#2850): See PR #3009. Thank you to @sgade for raising the issue.
- Equality operator shows incorrect values based on value of
__fulfilled
(#2944): See PR #2990. Thank you to @scottasoutherland for raising the issue.
- Add option to generate objects with
internal
access modifier (#2630): See PR #2917. Thank you to @simonbilskyrollins for the feature request.
@dynamicMember
conflicting field name (#2950): The subscript setters have been changed to allow a selection set property namedhash
. #2965 Thank you to @renanbdias for raising the issue.- Disallow certain targetNames in code generation (#2958):
apollo
is no longer allowed as a target name otherwise it causes a conflict when importingApollo
as a module. #2972 Thank you to @moopoints for raising the issue. - Fully Qualify name of RootEntityType and mergedSources (#2949): Selection set types use fully qualified namespacing to prevent conflicts with other types. #2956 Thank you to @martin-muller for raising the issue.
- SelectionSet Codegen
__typename
fix (#2955): Custom root types defined in the schema are now correctly applied to selection set fields typename definitions #2983 Thank you to @ynnadrules for raising the issue.
- Crash after calling
cancel()
onCancellable
(#2932): Callingcancel()
on a non-subscriptionCancellable
will now correctly handle the lifetime of the internallyUnmanaged
object. #2943 - Thank you to @yonaskolb for raising the issue. - Deprecation messages are not escaped (#2879): If escaped characters are used in GraphQL deprecation messages they are now properly escaped in the rendered Swift warning or attribution message. #2951 Thank you to @djavan-bertrand for raising the issue.
- Add injecting additionalErrorHandler for upload operations to RequestChainNetworkTransport (#2948):
Upload
operations can now have custom error interceptors like other operations. #2948 Thank you to @RobertDresler for the contribution.
- Version 1.1.0 does not compile when installed via CocoaPods (#2936): Module names not present in CocoaPods builds have been removed from type declarations. #2937 - Thank you to @simonliotier for raising the issue.
- Crash when using mocks for Double Nested Arrays (#2809): Test mock data is now correctly applied to the selection set. #2939 - Thank you to @scottasoutherland for raising the issue.
- In 1.1.0, passing custom scalars or GraphQLEnum to mocks fails (#2928): Test mock data is now correctly applied to the selection set. #2939 - Thank you to @scottasoutherland for raising the issue.
Apollo iOS v1.1 primarily focuses on adding generated initializers to the generated operation models.
In most cases, the upgrade from v1.0 to v1.1 should require no changes to your code.
- Changed generated fragment accessors with inclusion conditions: When conditionally spreading a fragment with an
@include/@skip
directive that has a different parent type than the selection set it is being spread into, the shape of the generated models has changed.- For example, a fragment accessor defined as
... on DetailNode @include(if: $includeDetails)
would have previously been namedasDetailNode
; it will now be generated asasDetailNodeIfIncludeDetails
.
- For example, a fragment accessor defined as
- While no breaking changes were made to official public APIs, some underscore prefixed APIs that are
public
but intended for internal usage only have been changed.- SelectionSet fulfilled fragment tracking:
SelectionSet
models now keep track of which fragments were fulfilled during GraphQL execution in order to enable conversions between type cases. While this does not cause functional changes while using public APIs, this is a fundamental change to the way that the underlying data for aSelectionSet
is formatted, it is now required that allSelectionSet
creation must be processed by theGraphQLExecutor
or a generated initializer that is guaranteed to correctly format the data. This means that initializing aSelectionSet
using raw JSON data directly will no longer work. Please ensure that raw JSON data is only used with the newRootSelectionSet.init(data: variables)
initializer.
- SelectionSet fulfilled fragment tracking:
- Null/nil value parsing issues. In some situations, writing/reading
null
ornil
values to the cache was causing crashes in 1.1 Beta 1. This is now fixed.
- Configuration option for generating initializers on SelectionSet models: You can now get initializers for your generated selection set models by setting the
selectionSetInitializers
option on your code generation configuration. Manually initialized selection sets can be used for a number of purposes, including:- Adding custom data to the normalized cache
- Setting up fixture data for SwiftUI previews or loading states
- An alternative to Test Mocks for unit testing
- Safe initialization of
SelectionSet
models with raw JSON: In 1.0, initializingSelectionSet
models with raw JSON was unsafe and required usage of underscore prefixed APIs that were intended for internal usage only. Apollo iOS 1.1 introduces a new, safe initializer:RootSelectionSet.init(data: variables)
.- Previously, if you provided invalid JSON, your selection set's were unsafe and may cause crashes when used. The new initializer runs a lightweight version of GraphQL execution over the provided JSON data. This quickly parses, validates, and transforms the JSON data into the format required by the
SelectionSet
models. If the provided data is invalid, this initializerthrows
an error, ensuring that your model usage is always safe.
- Previously, if you provided invalid JSON, your selection set's were unsafe and may cause crashes when used. The new initializer runs a lightweight version of GraphQL execution over the provided JSON data. This quickly parses, validates, and transforms the JSON data into the format required by the
- Added support for multipart subscriptions over HTTP.
- Generate
__typename
selection for generated models: In 1.1, the code generator adds the__typename
field to each root object. In previous versions, this selection was automatically inferred by theGraphQLExecutor
, however generating it directly should improve performance of GraphQL execution.
This is the first Beta Release of Apollo iOS 1.1. Version 1.1 primarily focuses on adding generated initializers to the generated operation models.
While no breaking changes were made to official public APIs, some underscore prefixed APIs that are public
but intended for internal usage only have been changed.
- Configuration option for generating initializers on SelectionSet models: You can now get initializers for your generated selection set models by setting the
selectionSetInitializers
option on your code generation configuration. Manually initialized selection sets can be used for a number of purposes, including:- Adding custom data to the normalized cache
- Setting up fixture data for SwiftUI previews or loading states
- An alternative to Test Mocks for unit testing
- Safe initialization of
SelectionSet
models with raw JSON: In 1.0, initializingSelectionSet
models with raw JSON was unsafe and required usage of underscore prefixed APIs that were intended for internal usage only. Apollo iOS 1.1 introduces a new, safe initializer:RootSelectionSet.init(data: variables)
.- Previously, if you provided invalid JSON, your selection set's were unsafe and may cause crashes when used. The new initializer runs a lightweight version of GraphQL execution over the provided JSON data. This quickly parses, validates, and transforms the JSON data into the format required by the
SelectionSet
models. If the provided data is invalid, this initializerthrows
an error, ensuring that your model usage is always safe.
- Previously, if you provided invalid JSON, your selection set's were unsafe and may cause crashes when used. The new initializer runs a lightweight version of GraphQL execution over the provided JSON data. This quickly parses, validates, and transforms the JSON data into the format required by the
- Added support for multipart subscriptions over HTTP.
- SelectionSet fulfilled fragment tracking:
SelectionSet
models now keep track of which fragments were fulfilled during GraphQL execution in order to enable conversions between type cases. While this does not cause functional changes while using public APIs, this is a fundamental change to the way that the underlying data for aSelectionSet
is formatted, it is now required that allSelectionSet
creation must be processed by theGraphQLExecutor
or a generated initializer that is guaranteed to correctly format the data. This means that initializing aSelectionSet
using raw JSON data directly will no longer work. Please ensure that raw JSON data is only used with the newRootSelectionSet.init(data: variables)
initializer. - Generate
__typename
selection for generated models: In 1.1, the code generator adds the__typename
field to each root object. In previous versions, this selection was automatically inferred by theGraphQLExecutor
, however generating it directly should improve performance of GraphQL execution. - Changed generated fragment accessors with inclusion conditions: When conditionally spreading a fragment with an
@include/@skip
directive that has a different parent type than the selection set it is being spread into, the shape of the generated models has changed. This does not affect generated call sites, but only affects the generatedselection
metadata used internally by theGraphQLExecutor
.
- Couldn't build when using some reserved words in a schema (#2765):
for
has been added to the list of reserved keywords that are escaped with backticks when used in schema types and operations. #2772 - Thank you to @torycons for raising the issue. - Subscript GraphQL variable from dictionary crash when Swift modifier used as key (#2759): Backticks have been removed from subscript keys of input objects. #2773 - Thank you to @SzymonMatysik for raising the issue.
- Unnamed fields in schema results in broken generated Swift code (#2753): The
_
character can be used as a GraphQL field name. #2769 - Thank you to @neakor for raising the issue. - LocalCacheMutation with an enum field fails (#2775): When writing selection set data back into the cache, custom scalars are now re-encoded back into their
_jsonValue
. #2778 - Thank you to @dabby-wombo for raising the issue. - DataDict subscript function crashes on iOS 14.4 and under (#2668):
AnyHashable
conversions when accessingDataDict
properties now perform checks on the base type. #2784 - Thank you to @bdunay3 for raising the issue. @include
directive based on variable with default value drops the included data (#2690): The GraphQL executor will now correctly evaluateGraphQLNullable
conditional variables. #2794 - Thank you to @klanchman for raising the issue.- Interfaces implemented by schema root are not generated (#2756): Interfaces references on the root type Query, Mutation or Subscription are now included in the schema module. #2816 - Thank you to @litso for raising the issue.
- HTTP headers format in schema download configuration JSON (#2661):
HTTPHeaders
in theApolloSchemaDownloadConfiguration
section of the codegen configuration JSON file can now be specified using the more intuitive format{ "Authorization": "<token>"}
. #2811 - Thank you to @nikitrivedii for raising the issue.
- Quotes in operation identifiers are not escaped (#2671): Query strings are now enclosed within extended delimiters to allow inclusion of special characters such as quotation marks. #2701 - Thank you to @StarLard for raising the issue.
- Cannot find type
graphQLSchema
in scope (#2705): Generated fragments now use the correct schema namespace casing. #2730 - Thank you to @iAmericanBoy for raising the issue. - Updating a local cache mutation with an optional field fails with a
ApolloAPI.JSONDecodingError.missingValue
error (#2697): Cache mutations will now allow incomplete data to be written to the cache without expecting all fields to be set. Please note that cache manipulation is an advanced feature and you should be aware of how the data written will affect network requests and cache policies. #2751 - Thank you to @amseddi for raising the issue. GraphQLEnum
value camel case conversion strategy (#2640), (#2749): The camel case conversion logic for GraphQL enums has been improved to handle a wider range of edge cases that were causing invalid Swift code generation. #2745 - Thank you to @ddanielczyk and @hispanico94 for raising the issues.- Naming collision with
Selection
type from apollo (#2708):ParentType
andSelection
types in generated selection sets now use a fully qualified namespace to prevent typename conflicts. #2754 - Thank you to @tahirmt for raising the issue. - Namespace collision when using "Schema" for
schemaName
(#2664): Certain strings are now disallowed for use as the schema namespace. #2755 - Thank you to @StarLard for raising the issue. - Naming collision with fragments and scalars (#2691): Shared referenced schema types will always use the fully qualified names as the types of fields in selections sets. This prevents collisions with names of other generated selection sets for entity type fields whose names are the same as a referenced schema type. #2757 - Thank you to @scottasoutherland for raising the issue.
- Naming collision with
DocumentType
in generated mock code (#2719): All shared referenced schema types within test mocks now use a fully qualified named type. #2762 - Thank you to @dafurman for raising the issue. - Schema/Target/Module name with spaces in it breaks generated code (#2653): Spaces are no longer allowed in the schema namespace. Additional validation has been added to the CLI commands to provide the correct error response. #2760 - Thank you to @Narayane for raising the issue.
- Raised minimum required tooling versions: Swift 5.7 and Xcode 14 are now the minimum required versions to build Apollo iOS and the generated code. #2695
- Fixed - Missing SPM plug-in: The missing Swift Package product has been added and the
Install CLI
plug-in is now available from the SPM command line and the Xcode project menu. #2683
- Fixed - Convenience initializer for mock objects without fields: When mock objects did not have any fields a convenience initializer would still be generated causing infinite recursion during initialization. #2634 Thank you to @Gois for the contribution!
- Fixed - Ambiguous use of operator '??': When the nil coalescing operator was used on variables without a type the compiler could not determine which one to use. #2650. Thanks to @skreberem for raising the issue.
- Fixed - Generate library for test mock target: Previous versions would generate the SPM target for test mocks but not a library to properly import it into your unit tests. #2638 Thank you to @Gois for the contribution!
- Fixed - Podspec Swift version mismatched with SPM package version: The Swift version is now the same between the two dependency managers. #2657
- Fixed - Conflicting configuration values: There is now an error during code generation when the given configuration has conflicting values that cannot be fulfilled. #2677
- Fixed -
DocumentType
namespacing: The correct module namespacing is now used forDocumentType
in generated operation code. #2679
- New - CLI version checker: This ensures that the version of the CLI being used to generate Swift code is the same as the version of the Apollo iOS dependency being used. #2562
- Changed - Removed SPM plug-ins: The SPM plug-ins for the CLI commands
init
,fetch-schema
, andgenerate
have been removed. There is a new plug-in to install the CLI and the CLI commands should be used from the command line instead. #2649 - Changed - CLI defaults: The updated default for the output of operation files is now
.inSchemaModule
, and theinit
command now requires a module type to be specified when creating a configuration file. #2673
- Fixed - Generated code produces compile error when accessing
data
dictionary in theInputDict
struct if the name of the accessed property ishash
: Dyanamic Member Lookup has been removed fromInputDict
to prevent potential name clashes. #2607 - Fixed - XCFramework archive builds:
@inlinable
has been removed from parts ofApolloAPI
that were preventing xcframework builds with theBUILD_LIBRARY_FOR_DISTRIBUTION
build setting. #2613 - Fixed -
Variables
type in local cache mutations is not properly namespaced: TheVariables
type inLocalCacheMutation
now has the required prefix ofGraphQLOperation
to build successfully. #2615 - Fixed - Return error if no matches to schema or operation search paths: When a schema file could not be found errors were emitted but they were not indicative of the underlying problem. There is now validation to ensure that at least one match of the schema/operation search paths is found otherwise an error is thrown. #2618
- Fixed - File generation should ignore the
.build
/.swiftpm
/.Pods
folders: If code generation was executed from a path where subfolders contained the apollo-ios repo, it would find internal test schemas and fail. These special folders are now ignored. #2628 - Fixed - Download schema relative to root URL: Even though a root URL could be provided it was not being used in all schema download logic to output the downloaded schema file to the correct locaiton. This is now fixed. #2609 Thanks to @Anteo95 for the contribution.
- Fixed - Not generating code for subtypes only used as input to mutations: If you are using a JSON format schema that was fetched via GraphQL introspection code generation will now generate all referenced subtypes. #2583 Thank you to @vrutberg for reporting the issue.
- Fixed - When using the test mock, touching a
GraphQLEnum
property will cause a crash: JSON Encoding the mocks into theSelectionSet.DataDict
was causingCustomScalar
values to get encoded into their JSON values. The mock data is now converted into the correct format for theSelectionSet.DataDict
. #2584 Thank you to @asapo for reporting the issue. - Fixed - Add namespace for ApolloAPI types in generated code: The Apollo
DocumentType
enum is now correctly namespaced in generated code. #2585 Thank you to @matijakregarGH for reporting the issue. - Fixed - Problems with schema name in generated code:
- Fixed - Test mocks crash when touching array of objects: Test mock list of objects is now correctly converted into selection set data. #2591 Thank you to @konomae for reporting the issue.
- Fixed:
GraphQLNullable
nil coalescing: @exported import statements now ensure that the operator overload is imported when using the generated models. #2600 Thank you to bassrock for reporting the issue.
- Fixed - apollo-ios-cli code generation on CocoaPods installation: All required resources for the CLI are now bundled correctly. This was an issue in CocoaPods installations where the
generate
command ofapollo-ios-cli
would result in a fatal error. #2548 Thank you to @ilockett for reporting the issue. - Fixed - Xcode integration for Swift Package Plugins: The SwiftPM plugins now support
XcodePluginContext
from Xcode 14 and accepts the additional command line options that Xcode sends. #2554 Thank you to @SilverTab for reporting the issue. - Fixed - Escaping input param names: Input parameter names recognized as reserved words are now escaped to prevent build errors. #2561 Thank you to @puls for the contribution.
- Fixed - Multiline deprecation messages: Deprecation messages that span multiple lines would previously result in build errors. #2579 Thank you to @TizianoCoroneo for the contribution.
- Changed - Warnings for deprecated enums: Deprecated enum cases are no longer annotated with the Swift
@available
attribute. They will now have comments indicating their deprecated status. #2579
This is the first major version release of Apollo iOS! The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
In a nutshell, v1.0.0 brings:
- A new code generation engine built entirely in Swift
- Improvements to the generated models
- Syntax and performance improvements across the entire library
There is documentation and a blog post coming soon. Feel free to ask questions by either opening an issue on our GitHub repo, or joining the community.
Thank you to all contributors who have helped us get to this first major release! ❤️
This is the first Release Candidate for Apollo iOS 1.0. The Release Candidate is a fully featured and code-complete representation of the final 1.0 version. This includes full feature parity with the 0.x.x releases.
API breaking changes are not expected between the Release Candidate and the General Availability (GA) release. The only code changes will be non-breaking bug fixes due to user feedback. The Release Candidate does not have complete documentation or usage guides, which will be completed prior to GA.
This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- New: Option to Include Deprecated Input Arguments on Fields During Schema Download Thanks to @dave-perry for this addition!
- Fixed: Code Generation Config JSON File Compatibility
- Previously, the
apollo-codegen-config.json
file used by the Apollo CLI needed to contain values for all optional fields. When new codegen options were added, this would cause errors until all newly added options has values provided. - The
Codable
implementation for theApolloCodgenConfiguration
has been implemented manually to prevent this. Now, only required fields must be provided, all optional fields can be omitted from the config file safely. - The CLI's
init
command also now generates a template config file with only the required fields.
- Previously, the
- Fixed: Swift Keywords are escaped when used as names of Input Parameters
- Fixed: Compilation Error when using
@skip
and@include
conditions on the same field - Fixed: Added permissions request to SPM Code Generation Plugin
- When running the code generation plugin, you will be prompted to give permission for the plugin to write to the package directory.
- This permission check can be avoided by passing the
--allow-writing-to-package-directory
flag when executing the plugin command.
- Fixed: APQ Operations Will no Longer be Retried when Unrecognized if using
.persistedOperationsOnly
.persistedOperationsOnly
is for use with allow-listed operations only. If an operation identifier is not recognized by the server, there is no way to register the operation in this configuration.
- Breaking: Updated
ApolloAPI
internal metadata properties to be__
prefixed.- Generated GraphQL files expose certain properties/functions that are consumed by the
Apollo
library during GraphQL Execution. These members must be public in order to be exposed toApollo
, but are not intended for external consumption. We have added underscore prefixes to each of these members to signify that intention, using__
for GraphQL Metadata (in alignment with the GraphQL Specification) and_
forApollo
's utility and helper functions. - The affected signatures are:
SelectionSet.schema
->SelectionSet.__schema
SelectionSet.selection
->SelectionSet.__selection
JSONEncodable.jsonValue
->JSONEncodable._jsonValue
JSONDecodable.init(jsonValue:)
->JSONDecodable.init(_jsonValue:)
AnyHashableConvertible.asAnyHashable
->AnyHashableConvertible._asAnyHashable
OutputTypeConvertible.asOutputType
->OutputTypeConvertible._asOutputType
GraphQLOperation.variables
->GraphQLOperation._variables
LocalCacheMutation.variables
->LocalCacheMutation._variables
- Generated GraphQL files expose certain properties/functions that are consumed by the
This is the fourth Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.
This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- Breaking: Generated Files now have the file extension
.graphql.swift
.- This allows you to clearly distinguish which files in your project are Apollo generated files.
- Generated template files that are user-editable will still have the
.swift
file extension.CustomScalar
templates as well as theSchemaConfiguration
file are user-editable. Once these are generated, they are never overwritten by future code generation execution.
- This change is also necessary for the identification of generated files for the pruning functionality.
- New: Pruning of Unused Generated Files
- Generated files that no longer should exist are automatically deleted now. This occurs when a
.graphql
file is removed from your project. The generated file will also be deleted the next time code generation is run. - This can be disabled with the new
pruneGeneratedFiles
codegen option. - Breaking: Automatic Deletion will not delete files generated in previous Alpha/Beta versions.
- Only files with the
.graphql.swift
file extension will be deleted. - If you have used previous Alpha/Beta versions, you will need to delete your generated files manually one last time before running code generation with this version.
- Only files with the
- Generated files that no longer should exist are automatically deleted now. This occurs when a
- New: Enum Case Names are Converted to Camel Case in Generated Enums.
- Breaking: This is enabled by default, your call sites will need to be updated.
- Camel case conversion for enum cases can be disabled with the new
conversionStrategies.enumCases
codegen option. - Thanks @bannzai for this one!
- Fixed: Swift Keywords are escaped when used as names of Enum Values Thanks @bannzai for the fix!
- Fixed: Compilation Error when Using Fragment with Lowercased Name This was an edge case that only occured when referencing a nested, merged selection set from the lowercase named fragment.
- Fixed: Retain Cycle in
ReadTransaction
Thanks @lorraine-hatch for the fix! - Fixed: String
jsonValue
Initializer for Large Numbers Thanks @Almaz5200 for the fix!
This is the third Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.
This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- Breaking: Changed the generated Schema files
- The schema will now have two generated files,
SchemaMetadata.swift
andSchemaConfiguration.swift.
- We wanted to more clearly separate the parts of the schema that are generated for you (metadata) from the parts that you can configure yourself (configuration).
- *If you were using the last beta, you’ll need to move your cache key resolution logic into
SchemaConfiguration.swift
. You should also delete the old generated files. - We will be implementing automatic deletion of generated files that should no longer be part of your project in a future beta, so you won't need to delete those files manually anymore.
- The schema will now have two generated files,
- New: Added SPM Plugin for Code Generation CLI
- When including Apollo iOS via Swift Package Manager, the Code Generation CLI is now accessible as an SPM Plugin.
- After installing the
apollo-ios
package, runswift package --disable-sandbox apollo-initialize-codegen-config
to create the codegen configuration file. - Then you can run
swift package --disable-sandbox apollo-generate
to run code generation. - The
--disable-sandbox
or--allow-writing-to-directory .
arguments must be used when running the Code Generation CLI via the SPM plugin to give the plugin permission to write the generated files to the output directory configured in your codegen configuration file.
- Fixed: Compilation errors when schema types had lowercase names
- Fixed: Codegen engine crashing in specific situations
- There were some bugs in the codegen compiler when merging nested fragments with non-matching parent types and using default values for input object list fields.
- Fixed: Issues with websocket reconnections Thanks @STomperi for the fix!
This is the second Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.
This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
Breaking: Changed API for Cache Key Configuration: Cache Key Resolution is now easier to configure. See CacheKeyInfo
for examples and documentation.
Breaking: Changed API for generated Schema Types to support dynamic types The API for generated schema types now initializes instances of Object
, Interface
, and Union
for each corresponding type in your schema. These are still generated by the code generation engine. This differs from the previous API which generated static types that were subclasses of Object
, Interface
, and Union
. The change provides the API to support the future addition of dynamic types added to your schema at runtime.
New: Codegen CLI will now automatically create output directories: You no longer are required to have already created all intermediary directories for your codegen output paths prior to running code generation.
New: Codegen CLI is built locally with CocoaPods installations: This is to ensure that the version of the Codegen CLI is the same as ApolloCodegenLib. This behaviour will be extended to Swift Package Manager installations too.
New: Swift Keywords are escaped when used as names of fields or types in generated objects: Previously, using Swift keywords (eg. self
, protocol
, Type
) as the names of fields in your operations or types in your schema would cause compilation errors in your generated code. Now, these names will be escaped with backticks to prevent compiler errors. The names \_\_data
and fragments
cannot be used as field names as they conflict with Apollo's generated object APIs Using these names will result in a validation error being thrown when attempting to run the code generation engine.
Fixed: Fragments with lowercase names caused compilation errors: This bug is fixed. Fragments with lowercase names will be correctly uppercased when referencing the generated Fragment
objects.
Fixed: Build errors in Xcode 14/Swift 5.7: The library was updated to support the Swift 5.7 language version. Swift 5.6 is still supported.
Fixed: Xcode 14 does not support Bitcode: Starting with Xcode 14, bitcode is no longer required for watchOS and tvOS applications, and the App Store no longer accepts bitcode submissions from Xcode 14.
Fixed: "No such module ApolloAPI
" error when using CocoaPods: The podspec was not configured to import all required source files and some import statements were unnecessary in a CocoaPods environment. A code generation configuration option was added to order to ensure generated files are generated with the correct import statements in a CocoaPods environment. When generating code for a project that includes Apollo
via Cocoapods, you must set the cocoapodsCompatibleImportStatements
option to true
in your ApolloCodegenConfiguration
. When using the Codegen CLI that is built for you during pod install
the apollo-ios-cli init
command will default this option to true
. When building the Codegen CLI in by other method, this option will default to false
.
Removed: ApolloUtils target no longer necessary: The things that used to be shared here are actually no longer shared. There is no code shared between the Apollo
and ApolloCodegenLib
targets.
Removed: ApolloCodegenConfiguration.validation: This method was incorrectly requiring destination paths to exist before code generation. Once that was removed it was no longer necessary. Any errors that are encountered with destination output paths will be raised during code generation.
This is the first Beta Release of Apollo iOS 1.0. The Beta version has full feature parity with the 0.x.x releases. The API is expected to be mostly stable. Some breaking changes may occur due to user feedback prior to General Availability (GA) Release. The Beta does not have complete documentation or usage guides, which will be completed prior to GA.
This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- New: Additional Generated Code Output Configuration Options.
queryStringLiteralFormat
: Configures how the generated operations render the operation document source. Either multi-line (as defined in operation definition) or minified to a single line.schemaDocumentation
: Documentation of fields and objects from your schema will now be included as in-line documentation on generated objects. This can be disabled by settingschemaDocumentation
to.excluded
in your codegen configuration.warningsOnDeprecatedUsage
: Adds warning annotation when using fields and arguments in generated operations that are deprecated by the schema.additionalInflectionRules
: Allows you to configure custom singularization rules for generated fields names.
- New: Support Automatic Persisted Queries: APQs are now fully functional. Note: Legacy operation safelisting support may experience issues in some cases. If you have problems using operation safelisting, please create an issue so that we may understand and resolve the edge cases in the safelisting process.
- Fixed: Singularization of plural names for non-list fields.
- Fixed: Runtime failure on execution of operations with InputObjects.
- Fixed:
__typename
field no longer generated when manually included:__typename
is automatically included in all operations and fragments and has a default property on all Selection Sets. Generating the field was redundant and caused compilation errors.
This is the eighth Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- New: Added
Equatable
andHashable
Conformance to public API Models: Object's likeGraphQLRequest
andGraphQLError
now can be compared! - New: Code Generation now supports Schema Extensions.
- Fixed: Namespacing and Access Control on Generated Models: Generated models were failing to compile due to namespacing and access control issues in certain code generation configurations. This is fixed now!
- Improved: Custom Scalar Default Float Behavior: If the response for a custom scalar is provided as a
Float
, it will automatically be converetd to aString
(just like it's always done forInt
). - Improved: GraphQL Float now treated as Swift Double: The
Float
defined in the GraphQL spec is actually compliant with a SwiftDouble
. Generated code will now generate Swift code with fields of typeDouble
for GraphQLFloat
. - Improved: Rename
SelectionSet.data
toSelectionSet.__data
: This is to prevent naming conflicts with GraphQL fields nameddata
. - Fixed:
graphql_transport_ws
protocol now sends 'complete' to end subscription: The protocol implementation was previously sending the wrong message to close the connection. - Improved: Generated Operations Folder Structure: The generated output folder structure for fragments and operations are now organized into sub-folders.
- New: Introspection Schema Download can output JSON: Schema downloads via Introspection now support output as JSON instead of only SDL. Note that Apollo Registry schema downloads still only support SDL as the output.
This is the seventh Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- New: Local Cache Mutations are now supported: In order to perform a local cache mutation, define a
.graphql
file with an operation or a fragment and mark it with the directive@apollo_client_ios_localCacheMutation
. This will ensure the code generator generates a mutable cache mutation operation.- Note: Local Cache Mutation operations cannot be used for fetching from the network! You should define separate GraphQL operations for network operations and local cache mutations.
- Example Usage:
/// SampleLocalCacheMutation.graphql
query SampleLocalCacheMutation @apollo_client_ios_localCacheMutation {
allAnimals {
species
skinCovering
... on Bird {
wingspan
}
}
}
/// SampleLocalCacheMutationFragment.graphql
fragment SampleLocalCacheMutationFragment on Pet @apollo_client_ios_localCacheMutation {
owner {
firstName
}
}
- New: Support Code Generation Configuration Option:
deprecatedEnumCases
: IfdeprecatedEnumCases
is set toexclude
, deprecated cases in graphql enums from your schema will not be generated and will be treated as unknown enum values. - Fixed - Compilation Errors in Generated Code When Schema was Embedded In Target: When embedding the generated schema in your own target, rather than generating a separate module for it, there were compilation errors due to access control and namespacing issues. These are resolved. This fixes #2301 & #2302. Thanks @kimdv for calling attention to these bugs!
- Note: Compilation Errors for Test Mocks are still present. We are aware of ongoing issues with generated test mocks. We are actively working on fixing these issues and they will be resolved in a future alpha release soon.
- Fixed: Crash When Accessing a Conditionally Included Fragment That is Nil. This is fixed now and will return
nil
as it should. This fixes #2310.
This is the sixth Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- New: Objects and InputObjects are now equatable: Many objects now conform to
AnyHashable
bringing with them the ability to conform toEquatable
, this should make tests easier to write. - Change: GraphQLOperation fields are now static: Previously an instance of a GraphQLOperation was required to query any of it's properties, you can do that on the type now.
- Fixed - Nested fragment type cases: Nested fragment type cases were not being generated causing a crash in selection set generation.
- New - Code generation now has a CLI: A new command line executable has been built and will be available on Homebrew very soon! Check it out here.
- Fixed - SelectionSet and InlineFragment protocol definitions: These were incorrectly being generated within the namespace when a module of type
.embeddedInTarget
was being used. - Fixed - Test mock convenience initializers: These were incorrectly definining parameter types for Interface and Union fields and the generated package could not successfully build.
This is the fifth Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- Test Mocks are now supported!
- Test mocks can be generated to make it much easier to create mocks of your generated selection sets for unit testing.
- This long requested feature can be enabled in your code generation config with the option
config.output.testMocks
. - Once you've generated test mocks, import the new
ApolloTestSupport
target (as well as your generated mocks) in your unit tests to start. - More documentation for test mocks will be coming soon. In the mean time, here is some example usage:
let mockDog = Mock<Dog>()
mock.species = "Canine"
mock.height = Mock<Height>(feet: 3, inches: 6)
// To mock an object in a generated operation:
let generatedDogMock: AnimalQuery.Data.Animal = AnimalQuery.Data.Animal.mock(from: mockDog)
// To mock an entire query:
let queryMock = Mock<Query>()
queryMock.animals = [mockDog]
let generatedSelectionSetMock: AnimalQuery.Data = AnimalQuery.Data.mock(from: queryMock)
GraphQLNullable
andGraphQLEnum
from theApolloAPI
target are now exported by your generated operations. This prevents you from having toimport ApolloAPI
everywhere that you are consuming your generated models.CacheKeyProvider
now supports grouping multiple types that share key uniqueness.- Lots of performance improvements
- Using
StaticString
instead ofString
in generated files. - Added
@inlinable
to manyApolloAPI
functions consumed by generated code. - And more!
- Using
This is the fourth Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- Client Controlled Nullability (CCN) is now supported!
- CCN is an experimental new feature addition to GraphQL. This feature allows you to override the optionality of fields from a schema in your client operations. CCN can help you create cleaner generated models that require less optional unwrapping.
- You can read more about CCN here.
- Because CCN is an experimental feature, the API is subject to change before its final release.
- Apollo iOS 1.0.0 is the first client to provide support for this new functionality! Huge thanks to @twof!
- Fixed - Names of generated objects are now correctly uppercased.
- Fixed - Names of inline fragments with inclusion conditions were sometimes generated incorrectly.
- Fixed -
__typename
field is now selected by executor on all entities automatically.
This is the third Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- Include/Skip Directives are now supported!
- Adding
@include/@skip
directives to fields, inline fragments, or fragment spreads will now generate code that respects the optionality of these conditionally included selections.
- Adding
- Changed - Generated TypeCase renamed to InlineFragment These are now used for both type cases and inline fragments that are conditionally included using
@include/@skip
directives. - Custom Scalars are now supported!
- Template Files will be generated for custom scalars. The template files
typealias
each custom scalar to aString
by default. These generated files can be edited to provide custom functionality for advanced custom scalars. Custom scalar template files that have been edited will not be overwritten on later code generation executions.
- Template Files will be generated for custom scalars. The template files
- Improved multi-module support
- Including your generated code using package managers other than SPM can be done using the
.other
option formoduleType
in your code generation configuration.
- Including your generated code using package managers other than SPM can be done using the
- **Nil Coalescing Operator added to
GraphQLNullable
- This allows for optional variables to easily be used with
GraphQLNullable
parameters and a default value
- This allows for optional variables to easily be used with
class MyQuery: GraphQLQuery {
var myVar: GraphQLNullable<String>
init(myVar: GraphQLNullable<String> { ... }
// ...
}
let optionalString: String?
// Before
let query = MyQuery(myVar: optionalString.map { .some($0) } ?? .none)
// After
let query = MyQuery(myVar: optionalString ?? .none)
- **Fixed -
fragments
not accessible on generatedSelectionSet
s. - **Fixed -
__typename
is now added to all operation and fragment definitions. - Fixed - Missing Generated Interface Types
- Interface types that were only referenced as an implemented interface of a referenced concrete type were not being generated previously.
This is the second Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- Operation Variables and Field Arguments are now supported!
- Fixed - Capitalized field names generate code that doesn't compile#2167
This is the first Alpha Release of Apollo iOS 1.0. This first major version will include a new code generation engine, better generated models, and many syntax and performance improvements across the entire library. The primary goal of Apollo iOS 1.0 is to stabilize the API of the model layer and provide a foundation for future feature additions and evolution of the library.
- The size of generated code has been reduced dramatically. In the most complex operations, the generated code can be up to 90% smaller than in the previous version.
- Generated response objects are more powerful and easier to consume.
- The response objects now intelligently merge fields from not only their parents, but also other matching siblings.
query AnimalQuery {
allAnimals {
species
... on Pet {
name
}
... on Cat {
furColor
}
}
In the past, the AsCat
model would have fields for species
, and furColor
, but to access the name
field, you would need to keep a reference to the AllAnimal
object and call AsPet.name
. This means that you couldn’t just pass the AsCat
object to a UI component.
In 1.0, because we know that Cat
implements the Pet
interface, the name
field is merged into the Cat
object.
Any property that should exist based on the type of the object will be accessible. This makes consuming our generated response objects in your applications much easier. This should greatly reduce the need for view models to wrap our generated response objects.
- The code generation engine is now written in native Swift! This makes it easier for Swift developers to contribute to the project or alter the generated code for their specific needs! In future iterations, we hope to open up the code generation templating API to allow for even easier customization of your generated code!
- Computation of Cache Keys is protocol oriented now. Instead of a single
cacheKeyForObject
closure on yourApolloClient
, you can implement cache key computation on individual object types with theCacheKeyProvider
protocol. See Cache Key Resolution in the RFC for more information.
- Remove all instances of bitcode as not supported in Xcode 14: Starting with Xcode 14, bitcode is no longer required for watchOS and tvOS applications, and the App Store no longer accepts bitcode submissions from Xcode 14. #2398 - Thanks to @stareque-atlassian for the contribution!
- Add codegen option for excludes: There is a new property on the codegen configuration options to allow files matching the pattern to be excluded, in the case they are found in the
includes
path. #2205 - Thanks to @bannzai for the contribution! - Fixed - Using the
graphql_transport_ws
protocol could result in4400
errors from the server: The correct protocol message is now being sent to the server to end communication. #2320 - Replace
print
statement withCodegenLogger.log
: All codegen output is logged withCodegenLogger
which can be disabled if needed. #2348 - Thanks to @hiltonc for the contribution! - Expose
GraphQLResultError
path string: Adds a new publicly available computed property toGraphQLResultError
which just exposes thepath
description. #2361 - Thanks to @joshuashroyer-toast for the contribution!
- Fixed - APQ Retrying Failing in 0.51.1: Fixes a bug introduced in the last version that broke APQs. Thanks to Kyle Browning for bringing this to our attention.
- Expose request body creation to better support custom interceptors: Enable lazy access to the request body creation for leverage in custom built interceptors, since JSONRequest.toURLRequest() encapsulates the creation. This enables the GraphQLMap to be accessed without re-creating the body. #2184 - Thanks to Rick Fast for the contribution.
- Allow periods in arguments to be ignored when parsing cacheKeys: If your query arguments include periods they will no longer cause broken cache keys. This means the cached data for those queries can be correctly found and returned. The caveat with this change though is that if you use a persisted cache, after the upgrade you could see cache misses and the data would be refetched. #2057 - Thanks to Hesham Salman for the contribution.
- Fixed -
Sendable
classJavaScriptError
cannot inherit from another class other thanNSObject
: Xcode 13.3 introduced some additional requirements forError
types andJavaScriptError
did not conform causing compile errors inApolloCodegenLib
. This change disablesSendable
type checking forJavaScriptError
while maintaining type-safety across concurrency boundaries. #2147 - Thank you to Tiziano Coroneo for the contribution. - Fixed - Watcher using a policy that shouldn't hit the network, can still hit the network: If the cache policy given to the
watch(query:cachePolicy:)
method ofApolloClient
was.returnCacheDataDontFetch
it could still trigger a remote fetch of the query. - Thank you to Peter Potrebic for raising the issue. - BREAKING CHANGE -
graphql-ws
Protocol Support: We've added official support for the graphql-ws library and itsgraphql-transport-ws
protocol. This is a breaking change because theWebSocket
initializers now require you to specify which protocol to use.
- Dropped SPM support for Swift 5.2: The minimum version of the Swift tools and language compatibilty required to process the SPM manifest is Swift 5.3. This means a minimum of Xcode version 12 is required for Swift Package Manager support. #1992
- Removed unnecessary assertion failure: The completion handler on
returnResultAsyncIfNeeded
is defined as optional but if not included would cause debug builds to crash with anassertionFailure
in the case of afailure
of theResult
. #2005 - Thank you to Richard Topchii for raising this issue! CachePolicy.default
is now a stored property: It is now easier to configure a different default value for theCachePolicy
property on anyApolloClient
instance instead of having to override it in a subclass. #1998 - Thank you to Tiziano Coroneo for the contribution!- Exposed
cacheKey
function aspublic
: The access modifier of this function onGraphQLField
has changed frominternal
topublic
. It is not recommended to rely on internal behaviour of the cache, and this is subject to change in future major versions. #2014 - Thank you to Peter Potrebic for the discussion! - GET method support for
ApolloSchemaDownloader
: Introspection-based schema downloads can now be queried using a GET request. #2010 - Thank you to Mike Pitre for the contribution! - Updated to version 2.33.9 of the Apollo CLI: This update will add
__typename
fields to inline fragments in operations to match the output from theclient:push
CLI command which used for operation safelisting. This should not affect the behaviour of your operations. #2028. - Updated to version 0.13.1 of SQLite.swift: This update brings in some iOS 14 fixes and new table functionality such as
upsert
andinsertMany
. #2015 - Thank you to Hesham Salman for the contribution.
ApolloSchemaDownloadConfiguration.HTTPHeader
initializer was not public: The struct initializer that Swift automatically generates is marked with theinternal
access level, which meant that custom HTTP headers could not be added to an instance ofApolloSchemaDownloadConfiguration
. #1962 - Thank you to Nikolai Sivertsen for the contribution!- Documentation update: Fixed an inline code block that had specified language where such specification is not supported. #1954 - Thank you to Kim Røen for the contribution!
- Fix - ApolloCodegenOptions could not find schema input file: - If you created
ApolloSchemaDownloadConfiguration
andApolloCodegenOptions
objects using only output folders the default output filename for the schema download was different from the default schema input filename for codegen. #1968 - Thank you to Arnaud Coomans for finding this issue!
- Breaking - Schema download is now Swift-based: The dependency on the Apollo CLI (Typescript-based) for schema downloading has been removed. Schema downloading is now Swift-based, outputs GraphQL SDL (Schema Definition Language) by default, and is maintainable/extensible within apollo-ios with full API documentation. This is a breaking change because some of the API signatures have changed. Swift scripting offers a convenient way to perform certain operations that would otherwise require the command line - it's worth a look if you haven't tried it yet. #1935
- Customizable subscription message identifiers: The
WebSocketTransport
initializer can be configured with a subclass ofOperationMessageIdCreator
to provide a unique identifier per request. The default implementation isApolloSequencedOperationMessageIdCreator
and retains the current behavior of sequential message numbering. #1919 - Thank you to Clark McNally for the contribution! - AWS AppSync Compatibility: Apollo-ios will now correctly handle the
start_ack
message that AWS AppSync servers respond with when a subscription is requested. #1919 - Thank you to Clark McNally for the contribution! - Updated to version 2.33.6 of the Apollo CLI: Applies some new vulnerability patches to the CLI, but should not change any output. #1929
- Improved documentation: Clarification of cache normalization concepts. #1710 - Thank you to Daniel Morgan for the contribution!
- Fixed - Websocket default implementation not included in
ApolloWebSocket
via Cocoapods: Thank you to ketenshi for the contribution!
- Breaking - Removed Starscream dependency: Due to dependency management conflicts it has become easier for us to maintain our WebSockets as part of the
ApolloWebSockets
target instead of an external dependency on a forked version of Starscream. #1906- Removed Starscream as an external dependency in Cocoapods and Swift Package Manager.
- The
DefaultWebSocket
implementation has been replaced withWebSocket
.
- Fixed -
clearCache
not using the provided callback queue:ApolloClient
was not passing the provided callback queue toApolloStore
and therefore the completion block forclearCache
was being called on the main queue. #1904, #1901 - Thank you to Isaac Ressler for the contribution! - Removed - Swift playground: The playground has been moved to a separate repository. #1905
- Removed - Swift experimental codegen: The experimental Swift code generation has been removed from
main
and will instead become available in therelease/1.0-alpha-incubating
branch until a 1.0 release. #1873 - Fixed - Query watcher not being called when the cache is updated on an element by another query/subscrition/mutation: The long-term solution is to integrate web sockets into the request chain but this is an interim fix that allows
WebSocketTransport
to be configured with a store to update the cache when receiving data. This should not break any workarounds others have already implemented. #1889, #1892 - Thank you to tgyhlsb for the contribution!
- Breaking - Downgraded from Starscream v4 to v3! After upgrading to Starscream 4.0, a lot of our users started to experience crashes while using web sockets. We've decided to revert to the more stable Starscream version 3. In order to fix a few known bugs in Starscream 3, we have made a fork of Starscream that Apollo will depend on going forward. In preparation for moving to Apple WebSockets in the future, we have also fully inverted the dependency on Starscream. Between these two changes, a lot of breaking changes to our Web Socket API have been made:
- The
ApolloWebSocketClient
protocol was removed and replaced withWebSocketClient
. WebSocketClient
does not rely directly on Starscream anymore and has been streamlined for easier conformance.ApolloWebSocket
, the default implementation of theWebSocketClient
has been replaced withDefaultWebSocket
. This implementation uses Starscream, but implementations using other websocket libraries can now be created and used with no need for Starscream.WebSocketClientDelegate
replaces direct dependency onStarscream.WebSocketDelegate
for delegates.
- The
- Breaking: Renamed some of the request chain interceptors object:
LegacyInterceptorProvider
->DefaultInterceptorProvider
LegacyCacheReadInterceptor
->CacheReadInterceptor
LegacyCacheWriteInterceptor
->CacheWriteInterceptor
LegacyParsingInterceptor
->JSONResponseParsingInterceptor
- Breaking:
WebSocketTransport
is now initialized with anApolloWebSocket
(or other object conforming to theApolloWebSocketClient
protocol.) Previously, the initializer took in the necessary parameters to create the web socket internally. This provides better dependency injection capabilities and makes testing easier. - Removed class constraint on
ApolloInterceptor
and converted to structs for all interceptors that could be structs instead of classes. - Added
removeRecords(matching pattern: CacheKey)
function to the normalized cache.
- BREAKING: Split
ApolloCore
into two more granular libraries,ApolloAPI
(which will contain the parts necessary to compile generated code) andApolloUtils
(which will contain code shared betweenApollo
andApolloCodegenLib
). If you were previously importingApolloCore
, in most places you will need to importApolloUtils
. If you're using Carthage, you will need to remove the oldApolloCore
xcframework and replace it with the twoApolloAPI
andApolloUtils
frameworks. (#1817) - Fixed a stray CocoaPods warning. (#1769)
- Updated the Typescript CLI to version 2.32.13. (#1773)
- Added the ability to specify a
cachePolicy
when callingrefresh
on aGraphQLWatcher
. (#1802)
- BREAKING (or hopefully, fixing): We removed our test libraries from our
Package.swift
file since we're not using it to run tests directly at this time. This prevents SPM from trying to resolve test dependencies that are not actually used in the library, which should reduce any version conflicts. However, if you were using any of our test libs in an unsupported fashion, these will no longer be directly available. (#1745) - Fixed an issue where when
Starscream
returned multiple errors in close succession, an exponential number of web socket reconnections could be created. (#1762) - Updated
class
constraints toAnyObject
constraints, which should silence a few warnings in 12.5 and be more forward compatible. (#1733) - Added the ability to specify a callback queue for the result handler of
GraphQLWatcher
. (#1723) - Fixed a crash when closing a web socket connection and re-opening it immediately. (#1740)
- You can now skip auto-reconnection for updating the header values and connecting payload in
ApolloWebSocket
. (#1759) - Now avoids the
?
when generating aGET
URL ifqueryItems
is empty. (#1729) - Updated use of the
default
fetch policy to include fetch and watch. Note that under the hood, this does not change what fetch policy was pointed to at this time, it just centralizes the logic. (#1737)
- BREAKING: Finally updates our
Starscream
dependency to 4.0.x. Note that due to SOCKS proxy support being removed fromStarscream
, we've correspondeingly removed such support.(#1659) - BREAKING, but only to Swift Scripting: Updated
ApolloSchemaOptions
to more clearly handle introspection (ie, from a URL) vs registry (ie, from Apollo Studio) requests by using an enum. If you were passing in anendpointURL
previously, you need to use the.introspection
enum value going forward. Also changed the name of the field to match the new type. (#1691) - BREAKING: Removed
CoadableParsingInterceptor
and related code designed for new codegen (which is still in progress) since we were wildly over-optimistic on how quickly we'd be using it. (#1670) - Fixed an issue where tasks that were in the
canceling
state could trigger aNo data found for task
assertion failure. (#1677) - Fixed an issue with encoding
+
inGET
requests. (#1653) - Fixed an issue where creating
GET
requests removed existing query params from the URL. (#1687) - Prevented a retain cycle during web socket reconnection. (#1674)
- Added better handling for calling
cancel
on aRequestChain
which has already been cancelled. (#1679)
- BREAKING: Fixed an issue in which
UploadRequests
were not getting headers added via theRequestChainNetworkTransport
'sadditionalHeaders
. Please note that if you've subclassed the RCNT, you'll need to update your overrides since we had to add a parameter. (#1644) - Stopped
GET
requests from sending aContent-Type
header, which could cause servers not configured to ignore that header when the body is empty to freak out. (#1649)
- BREAKING: Dropped support for iOS/tvOS < 12, watchOS < 5, and macOS < 10.14. This also involved removing a couple of public functions that were workarounds for support for lower versions. (#1605)
- Updated the typescript CLI to version
2.32.1
. There may be some structural changes to generated code but it should not actually break anything. Please file bugs immediately if it does. (#1618)
- POSSIBLY BREAKING: Updated
swift-tools
version to 5.3, and added a fallback version ofPackage.swift
for 5.2. (#1584) - BREAKING, technically: Switched
cachePolicy
to avar
onHTTPRequest
. This makes it possible for retries to use a different cache policy, such as when an error has occurred at the network level and you want to fall back to showing what's in the cache without retrying the network call. (#1569) - Added validation in Swift Codegen wrapper that a URL passed in for
singleFile
code generation is a.swift
file and a URL passed in formultipleFiles
code generation is a folder. (#1580)
- Fixes an issue that could cause callbacks to fail if a
retry
was performed in anadditionalErrorInterceptor
. (#1563)
- Updates a dependency used for Experimental Swift Codegen to use a version to fix an issue with resolution failures
- Updates
apollo-tooling
version to include a bugfix there. (#1554)
- BREAKING: We've made some significant (~4x) performance improvements to the cache and eliminated all our known Thread Sanitizer issues by removing some overly agressive multithreading and our internal Promises implementation. (#1531) Related Changes:
- POSSIBLY BREAKING: These improvements caused changes in our
NormalizedCache
andApolloClientProtocol
protocols, so if you're implementing these yourself, you'll need to update. - BREAKING: Removed the
loadRecords(forKeys:)
method onReadTransaction
. We'd recommended that you use eitherread
orreadObject
with the transaction, but if you were usingloadRecords
, you will need to shift to those other methds. - NEW:
ApolloStore
'sload(query:resultHandler:)
method now also takes an optional callback queue.
- POSSIBLY BREAKING: These improvements caused changes in our
- NEW: Added the ability to say whether the results from a mutation should be published to the store are not. This is a boolean value which defeaults to
true
, to match existing behavior. (#1521) - BREAKING: The setter for
Atomic
'svalue
is no longer public to prevent accidental misuse. If you were using this, use themutate
method instead to ensure the thread lock works properly. (#1538)
- POSSIBLY BREAKING: Updated behavior of
URLSessionClient
when it's been invalidated to throw an error instead of crashing. If you were relying on this failing loudly before, please be aware it's going to fail a lot more quietly now. (#1489) - Improved performance of
loadRecords
for the SQLite cache. (#1519) - Added support for use of
Apollo
as a dynamic lib. (#1483) - Updated the legacy CLI to
2.31.0
. (#1510) - Fixed some bugs in our
JSONSerialization
handling. (#1478) - Fixed an issue with callback queue handling for websockets. (#1507)
- Fixed an issue with callback queue handling for errors. (#1468)
- Removed a redundant
nil
check while clearing the cache. (#1508)
- POSSIBLY BREAKING: We removed some default parameters for the
ApolloStore
fromApolloClient
andLegacyInterceptorProvider
to prevent an issue where developers could accidentally create these objects with different caches. (#1461) - Added a new parameter to allow the option to not automatically connect a websocket on initialization. (#1458)
- BREAKING: Removed the now-unused-in-the-SDK
GraphQLHTTPResponseError
type. If you were relying on this class, please copy it out of v0.34.1. (#1437) - BREAKING: Removed default parameters from
RequestBodyCreator
's default implementation to fix an issue where when default parameters were passed, the compiler would always select the default implementation even if a full alternate implementation was provided. (#1450) - Removed unnecessary manual task clearing when invalidating a URLSession. (#1443)
- Fixes an issue that would cause headers to get lost when sending with
useGETForQueries
. (#1420)
- SPECTACULARLY BREAKING: As noted in the Beta release notes below, the networking stack for HTTP requests has been completely rewritten. This is described in great detail in the RFC for the networking changes, as well as the updated documentation for Advanced Client Creation and the updated tutorial section on setting up authentication. Thank you all for the excellent feedback and looking forward to hearing about the cool stuff you're able to build with this! (#1386)
- REMINDER: If you're using Carthage with Xcode 12, please make sure you're using the workaround script as outlined in the release notes for
0.33.0
.
Networking Stack, Release Candidate
- Made
RequestChainNetworkTransport
subclassable and changed two methods to beopen
so they can be subclassed in order to facilitate using subclasses ofHTTPRequest
when needed. (#1405) - Made numerous improvements to creating upload requests - all upload request setup is now happening through the
UploadRequest
class, which is nowopen
for your subclassing funtimes. (#1405) - Renamed
RequestCreator
toRequestBodyCreator
to more accurately reflect what it's doing (particularly in light of the fact that we didn't have aRequest
in the old networking stack, and now we do), and renamed associated properties and parameters. (#1405)
Networking Stack, Release Candidate
-
Added some final tweaks:
- Updated
ApolloStore
to take a default cache of theInMemoryNormalizedCache
. - Updated LegacyInterceptorProvider to take a default store of the
ApolloStore
with that default cache. - Added a method to
InterceptorProvider
to provide an error interceptor, along with a default implementation that returnsnil
. - Updated
JSONRequest
to be open so it can be subclassed.
This is now at the point where if there are no further major bugs, I'd like to release this - get your bugs in ASAP! (#1399
- Updated
Networking Stack, Beta 2
- Merges
0.33.0
changes into the networking stack for Swift 5.3 and Xcode 12.
- Adds support for Xcode 12 and Swift 5.3. (#1280)
- Adds workaround script for Carthage support in Xcode 12. Please see Carthage-3019 for details. TL;DR: cd into
[YourProject]/Carthage/Checkouts/apollo-ios/scripts
and then run./carthage-build-workaround.sh
to actually get Carthage builds that work. (#yolo committed tomain
)
Networking Stack, Beta 1
- SPECTACULARLY BREAKING: The networking stack for HTTP requests has been completely rewritten. This is described in great detail in the RFC for the networking changes, as well as the updated documentation for Advanced Client Creation. Please, please, please file bugs or requests for clarification of the docs as soon as possible. Note that all changes until the networking stack comes out of beta will live on the
betas/networking-stack
branch. (#1341)
- Improves invalidation of a
URLSesionClient
to include cancellation of in-flight operations. (#1376)
- Fixes an issue that would occur when a GraphQL query watcher's dependent keys would not get updated. (#1375)
- Adds an
extensions
dictionary property toGraphQLResult
. (#1370) - Makes a couple of response parsing helpers public for advanced use cases. (#1372)
-
Adds the ability to pause and resume a WebSocket connection without dumping existing subscriptions. (#1335)
-
Adds an initializer to
SQLiteNormalizedCache
that takes aSQLite.swift
DatabaseConnection
to more easily allow setup of pre-configured connections. (#1330) -
Addresses a retain cycle that could cause memory leaks when using multiple instances of
HTTPNetworkTransport
.NOTE: If you're using
URLSessionClient
outside the context ofHTTPNetworkTransport
, make sure to callinvalidate()
on it when whatever is holding onto it hitsdeinit()
to prevent leaks. (#1366)
- BREAKING: Updates the CLI to
2.30.1
to fix a long-standing issue where when generating operation IDs and their related JSON file, the correct operations + fragments would be used in generating the operation ID, but not output with the JSON file. This will slightly change the output inAPI.swift
, but it also means we can remove a related workaround from the iOS SDK. (#1316) - BREAKING: Removed the
Cartfile
which declared our dependencies, since we're now internally managing them with SPM, and newer versions of Carthage just use the SPM dependencies. Note that this can cause issues if you need to use a fork of dependencies, or if you're using an older version of Carthage. (#1311) - POSSIBLY BREAKING: Works around an issue that could cause some attempts to store untyped JSON dictionaries to throw unexpected errors about optional encoding. This also added handling of creating a dictionary from a
JSONValue
, which may cause problems if you've already implemented this yourself, but which should mostly just replace the need to implement it yourself. Please file issues ASAP if you run into problems here. (#1317) - Works around an issue causing some attempts to store arrays of JSON dictionaries to have arbitrary key ordering. (#1281)
- Adds clearer error descriptions to a few errors. (#1295)
- Updates the CLI to
2.28.3
to fix an issue where linter failures would cause a silent failure exit. (#1284, #1288](apollographql#1288)) - Adds a check to swift scripting that the downloaded file has the correct SHASUM, otherwise forcing redownload. (#1288)
- NEW: Swift scripting is officially out of Beta! Please check out our updated guide to integration. The tutorial should be updated to recommend using Swift Scripting within the next week or so. NOTE: The shell script is not deprecated yet, but will be shortly. (#1263)
- BREAKING: Found some workarounds to conditional conformance and updated all extensions to use the
apollo.extensionMethod
syntax introduced in0.28.0
. (#1256) - BREAKING: Moved a few things into the new
ApolloCore
library. For CocoaPods and SPM users, this should be automatically picked up by your package manager. Carthage users, you will need to drag the newApolloCore
library into your project manually as you have with the other Apollo libs. (apollographql#1256) - BREAKING: Updated to version
2.28.0
of the Apollo JS CLI. This includes moving a bunch ofstatic let
allocations to computedstatic var
s to prevent memory overuse. (#1246) - Made
GraphQLGetTransformer
and its methods public and made a couple more methods onMultipartFormData
public. (#1273) - Fixes an issue when uploading multiple files for different variables. (#1279, special thanks to #1081)
- Fixes a crash when encoding
GraphQLVariable
objects which conform toJSONEncodable
. (#1262)
- BREAKING: Changed a few things in the
ApolloCodegen
library to useobject.apollo.extensionMethod
syntax rather thanobject.apollo_extensionMethod
. There's a few things that are still usingapollo_
notation due to constraints around conditional conformance, but you should particularly check your swift scripts for changes aroundFileManager
APIs. (#1183) - BREAKING:
NormalizedCache
now has a method for explicitly clearing the cache synchronously, in addition to the existing method to clear it asynchronously. If you've got a customNormalizedCache
implementation, you'll need to add an implementation for this method. (#1186) - Fixed race conditions in
URLSessionClient
that were causing unexpected behavior. Turns out concurrency is hard! (#1227) - Improved handling of a dependent key update cancelling an in-flight server fetch on a watcher. (#1156)
- Added option to Swift Codegen to pass in a prefix for custom scalars. (#1216)
- Added ability to change a header on a websocket connection and automatically reconnect. (#1224)
- Better defense against multithreading crashes in
URLSessionClient
. (#1184) - Fix for watchOS availability for
URLSessionClient
. (#1175)
- BREAKING: Replaced calls directly into the closure based implementation of
URLSession
with a delegate-based implementation calledURLSessionClient
.-
This (finally) allows background session configurations to be used with
ApolloClient
, since background session configurations immediately error out if you try to use the closure-basedURLSession
API. -
This makes a significant change to the initialization of
HTTPNetworkTransport
if you're using a customURLSession
: BecauseURLSession
must have its delegate set at the point of creation,URLSessionClient
is now creating the URL session. You can initialize aURLSessionClient
with aURLSessionConfiguration
. if before you were using:let session = URLSession(configuration: myCustomConfiguration) let url = URL(string: "http://localhost:8080/graphql")! let transport = HTTPNetworkTransport(url: url, session: session)
You will now need to use:
let client = URLSessionClient(sessionConfiguration: myCustomConfiguration) let url = URL(string: "http://localhost:8080/graphql")! let transport = HTTPNetworkTransport(url: url, client: client)
-
If you were passing in a session you'd already set yourself up to be the delegate of to handle GraphQL requests, you'll need to subclass
URLSessionClient
and override any delegate methods off ofURLSessionDelegate
,URLSessionTaskDelegate
, orURLSessionDataDelegate
you need to handle. Unfortunately only one class can be a delegate at a time, and that class must be declared when the session is instantiated.Note that if you don't need your existing delegate-based session to do any handling for things touched by Apollo, you can keep it completely separate if you'd prefer.
-
This does not change anything at the point of calls - everything is still closure-based in the end
Please file bugs on this ASAP if you run into problems. Thank you! (#1163)
-
- BREAKING, though in a good way: Updated the typescript CLI to 2.27.2, and updated the script to pull from a CDN (currently backed by GitHub Releases) rather than old Circle images. This should significantly increase download performance and stability. (#1166)
- BREAKING: Updated the retry delegate to allow more fine-grained control of what error to return if an operation fails in the process of retrying. (#1128, #1167)
- Added support to the Swift scripting package to be able to use multiple headers when downloading a schema. (#1153)
- Added the ability to set the SSL trust validator on a websocket. (#1124)
- Fixed an issue deserializing custom scalars in
ApolloSQLite
. (#1144)
- Repoints download link to our CDN for the CLI for people on 0.25.0 who can't upgrade to 0.26.0 or higher immediately.
- BREAKING: Updated the
swift-tools
version to 5.2 inPackage.swift
. Note that if you're usingswift-tools
5.2, you'll need to update the syntax of yourPackage.swift
file and specify the name of the library manually for Apollo. (#1099, #1106) - POSSIBLY BREAKING: Upgraded the typescript CLI to 2.26.0. No changes were found in test frameworks, but this could theoretically break some stuff. (#1107, #1113)
- NEW: Added the ability to set Starscream's underlying
enableSOCKSProxy
to better allow debugging web sockets in tools like Charles Proxy. (#1108) - Fixed several issues using paths with spaces in the Swift Codegen. (#1092, #1097).
ApolloCodegenLib
is now properly passing theheader
argument last when downloading a schema. (#1096)- Automatic Persisted Queries now also work with mutations. (#1110)
- Repoints download link to our CDN for the CLI for people on 0.24.0 who can't upgrade to 0.26.0 or higher immediately.
- BREAKING: Updated
GraphQLResponse
to be generic over the response type rather than the operation type. This will allow more flexibility for generic modifications to methods that need to useGraphQLResponse
. (#1061) - BREAKING: Updated the file URL-based initializer of
GraphQL
to throw with a clear error instead of failing silently. Removed the ability to pass in an input stream since that can't be recreated on a failure. Updated initializers take either rawData
or a file URL so that the input stream can be recreated on a retry. (#1086, #1089) - In the Swift Package Manager based codegen, made sure that the folder the CLI will be downloaded to is created if it doesn't exist. (#1069)
- Repoints download link to our CDN for the CLI for people on 0.23.x who can't upgrade to 0.26.0 or higher immediately.
- Changed the
@available
flags added in 0.23.1 to#if os(macOS)
, since the former is runtime and the latter is compile time, to work around a bug where SwiftUI compiles theApolloCodegenLib
library even if it's not included in the target being previewed. (#1066) - Added support for
omitDeprecatedEnumCases
command line option I missed forApolloCodegenOptions
(#1053)
- Added some
@available
flags to prevent accidental compilation ofApolloCodegenLib
on platforms other than macOS. (#1041) - Made the
Query
onGraphQLQueryWatcher
public so it can be referenced. (#1037)
-
BETA: Now available, SPM-based code generation, Phase 0 of our transition to Swift Codegen.
Note that the underlying codegen is still using
apollo-tooling
, but that will change as we proceed with Phase 1 of the Swift Codegen Project, generating the code in Swift.Documentation is available at our Swift Scripting page.
When this gets to the final version this will supersede existing codegen, so please file bugs galore on this so we can get it good to go as quickly as possible. Thank you! (#940, #1033)\
-
Fixed some memory leaks in our internal Promises implementation. (#1016)
- Repoints download link to our CDN for the CLI for people on 0.22.0 who can't upgrade to 0.26.0 or higher immediately.
- BREAKING: Updated CLI to v2.22.1, including a bunch of fixes on the Swift side:
- Marked files which are generated as
@generated
- Added documentation to the constructors of input structs
- Added additional type annotations to improve compile times.
- Marked files which are generated as
- BREAKING: Updated delegate in
HTTPNetworkTransport
to be aweak var
and to not be passed in as a parameter to the initializer. (#990, #1002) - Added a lock to
InMemoryNormalizedCache
to reduce possible race conditions. (#552) - Added the ability to not send duplicates on a websocket. (#1004)
- Fixed an issue that could lead to an undefined cache key in the SQLite library. (#991)
- Fixed an issue where existing fetch operations in a watcher would not be canceled before a new one was started. (#1012)
- Repoints download link to our CDN for the CLI for people on 0.21.0 who can't upgrade to 0.26.0 or higher immediately.
- BREAKING, but by popular request: Removed the requirement that the
clientName
andclientVersion
onNetworkTransport
, and added a default implementation so custom implementations don't need to set these up themselves. (#954)
- Repoints download link to our CDN for the CLI for people on 0.20.0 who can't upgrade to 0.26.0 or higher immediately.
- Fixed a bunch of data races in
ApolloWebSocket
. (#880) - Updated
ApolloWebSocket
to depend onApollo
inPackage.swift
since there is a dependency there. (#906) - POSSIBLY BREAKING Updated Swift tools version in package declaration to 5.1. (#883)
- Repoints download link to our CDN for the CLI for people on 0.19.0 who can't upgrade to 0.26.0 or higher immediately.
- NEW: Added a retry delegate to allow retries based on GraphQL errors returned from your server, not just network-level errors. NOTE: Be careful with which errors you retry for - the mere presence of an error doesn't necessarily indicate a full failure since GraphQL queries can return partial results. (#770)
- NEW: Automatically generates ApolloEngine/ApolloGraphManager headers based on your main bundle's ID and version number. These can also be configured when you set up your
NetworkTransport
if you need something more granular for different versions of your application. (#858) - POSSIBLY BREAKING: The
NetworkTransport
protocol is now class-bound. If you built your ownNetworkTransport
implementation instead of one of the ones included with the library, this now must be aclass
instead of astruct
. (#770) - POSSIBLY BREAKING: Removed an
unzip
method for arrays of arays which we were not using. However, since it was public, we figured we should let you know. (#872) - Bumped Starscream dependency to
3.1.1
. (#873)
- Repoints download link to our CDN for the CLI for people on 0.18.x who can't upgrade to 0.26.0 or higher immediately.
- Removes TSAN from run on schemes to fix Carthage issue. (#862)
-
POSSIBLY BREAKING: Updated CLI to no longer be directly bundled, but to be downloaded if needed. This allows us to avoid bloating the iOS repo with the CLI zip, and to make it easier to test different versions of the CLI in the future. This change should automatically download the updated CLI version for you.
Note one significant change from prior bundled versions: If you are connected to the internet when you download the iOS dependency through SPM/Carthage/CocoaPods, you will now need to build your target while still connected to the internet in order to download the proper version of the CLI. Once the correct version of the CLI is downloaded, internet access should no longer be necessary to build. If you disconnect from the internet before the correct version downloads, you will not be able to build. (#855)
-
Updated version of CLI to download to
2.21.0
. (#855) This includes:- Ability to have the codegen ignore deprecated enum cases by using the
--omitDeprecatedEnumCases
flag - Fix for generating input fields for
null
values
- Ability to have the codegen ignore deprecated enum cases by using the
-
Fixes a number of weak references with closures. Note that this may reveal some places you weren't hanging onto a strong reference to your
ApolloClient
object, which will cause it to get deallocated. (#854)
- NEW: Support for Automatic Persisted Queries. This feature allows you to send the hash of a query to your server, and if the server recognizes the hash, it can perform the whole query without you having to send it again. This is particularly useful for large queries, since it can reduce the amount of data you have to send from your user's device pretty significantly. (#767)
- BREAKING: Removed old script files which have been deprecated. If you were still using these, please check out the updated codegen build step setup instructions to get up and running with the
run-bundled-codegen
script. (#820) - POSSIBLY BREAKING: Updated bundled CLI to v2.19.1. Please check out the CLI changelog for full details, but this version actually moves to using multi-line Swift strings for queries. If you prefer to have condensed queries, it also introduces a
--suppressSwiftMultilineStringLiterals
flag which produces single-line queries stripped of whitespace. (#831) - Fixed a couple places we were not using
LocalizedError
properly. (#818)
- Updated the way
run-bundled-codegen
checks whether the bundled codegen has already been unzipped and has node locally. (#806) - Updated how default parameters are provided for
RequestCreatorProtocol
. (#804)
- BREAKING: We've switched to a much simpler setup which does not involve NPM in order to use our CLI. This requires updating your build scripts. Please follow the updated instructions for setting up the build script here. The existing build script will continue to work until the next minor release, at which point it will be removed. (#766)
- Included CLI version fixes issues which showed up in
0.15.2
. - BREAKING: We've removed all public references to our internal
Promise
implementation, which was never intended to be public. (#709) - Fixed a deadlock in a transaction. (#763, #365)
- Added a
RequestCreatorProtocol
to allow you to more easily muck with and/or mock creating multipart requests. (#771) - Fixed an issue causing problems building with SPM in Xcode 11. (#784)
- Revert CLI update from
0.15.2
due to unexpected build issues.
-
Update Apollo CLI requirement to 2.18. This should pull in a couple fixes to the CLI:
- Way better escaping of identifiers, types, and strings (Tooling #1515)
- Fix compiler warning when an optional has a
.none
case (Tooling #1482)
If you run into any weird build issues after this update, try deleting your local
node_modules
folder and rebuilding before filing an issue. (#760) -
Better handling of the
localizedDescription
forHTTPResponseError
. (#756)
- Add platform name to framework bundle identifier to work around a change to app store submission. Please see the PR for more details. (#751)
- Expose the initializer for
GraphQLQueryWatcher
so it can actually be instantiated. (#750)
-
BREAKING: Finally swapped out
URLSessionConfiguration
on initializer forHTTPNetworkTransport
to useURLSession
directly instead. If you were previously passing in a configuration, first hand it to aURLSession
instance and then pass that instance into the initializer.This allows many new things including:
- Support for background sessions
- Easier mocking through
NSURLProtocol
- Certificate pinning
- Self-signed certificates
- Metrics inspection
- Authentication challenge handling
All these are pretty much entirely through the ability to use URLSessionDelegate
directly since we're now accepting a URLSession
you can declare yourself to be the delegate of rather than just the configuration. (#699, inspired by #265)
- BREAKING, though hopefully in a good way: Significant updates to the Upload functionality to make it conform more closely to the GraphQL Upload Spec. Also added a goodly bit of documentation around this functionality. (#707)
- Way better support for Swift Package Manager, especially for
ApolloSQLite
andApolloWebSocket
. (#674) - Created
ApolloClientProtocol
to match all public methods ofApolloClient
for easier mocking. (#715, inspired by #693)
-
BREAKING Updated codegen to use 2.17 of the Apollo CLI. Please see the full release notes for that version of the CLI, but in short:
- Stops force-unwrapping and instead nil-coalesce to
.none
when the thing being unwrapped was a double-optional, which was causing some crashes - Fixes issue where removing redundant modifiers was a little too aggressive
- Fixes escaping for
Self
as a type name - Adds
CaseIterable
for all known cases of an enum. If you were adding this yourself previously, you'll have to take it back out. - Adds comment with original operation to
operationDefinition
, stripped excess whitespace from actual definition.
- Stops force-unwrapping and instead nil-coalesce to
-
Added explicit support for Catalyst builds. (#688)
-
Added support for
Int
custom scalars. (#402) -
Exposed
clearCache
directly on stores so a store being used by multiple clients can be more explicitly cleared. (#518) -
Fixed an issue where an error on cache write would not be propagated correctly. (#673)
-
Updated supported Node version to the Long-Term Support version. (#672)
PLEASE READ THESE RELEASE NOTES BEFORE INSTALLING IF YOU WERE USING AN OLDER VERSION!
-
SUPER-BREAKING: Updated a ton of completion closures that could use it to use
Result
instead of optional parameter / optional error. (#644). There are a few details to this one to be particularly aware of:- If you see a bunch of Swift build errors that are claiming Generic Parameter "Query" could not be inferred, that means you need to update your completion closure to take the single
Result<Parameter, Error>
parameter instead of the two (Parameter?
,Error?
) parameters. - Particularly around caching, if there are places where both parameters were
nil
in previous iterations, you will now get anError
. This will generally be aJSONDecodingError.missingValue
, either as the direct error or as theunderlying
error of aGraphQLResultError
. Please check out the changes toFetchQueryTests
in PR #644 for a better look at how some of that has changed.
- If you see a bunch of Swift build errors that are claiming Generic Parameter "Query" could not be inferred, that means you need to update your completion closure to take the single
-
BREAKING: Updated the codegen to use v2.16 of the Apollo CLI. (#647). This is a major version change so some things need to be added, and some parameter names have changed:
- You must add
--target=swift
so the CLI knows to generate Swift code. - If you were using
--schema=schema.json
, use--localSchemaFile="schema.json"
instead (the quotes are required!). - If you were using
--queries="$(find . -name '*.graphql')"
to pass in an array of all your GraphQL files, use--includes=./*.graphql
instead.
If you get error messages about multiple versions of node when you attempt to run, delete the
node_modules
folder in your source root and rebuild.Upgrading fixes several issues:
operationName
is now generated for all operations.- Trailing newlines are now added to all generated files.
- You must add
-
NEW: Ability to upload files according to the GraphQL Multi-part request spec. (#626, #648, inspired by #116)
-
NEW: Now that
operationName
is generated for all operations, we're sending it along with all requests. (#657, inspired by #492) -
NEW: We're also sending
operationName
as theX-APOLLO-OPERATION-NAME
header and when anoperationIdentifier
is provided, sending that as theX-APOLLO-OPERATION-ID
header. (#658) -
NEW: Option to run
VACUUM
on your SQLite store when clearing to help obliterate all traces of data. (#652) -
NEW: Auto-generated API documentation from inline comments. Now available on the website NOTE: Any manual changes made to markdown files will get overwritten, if you want to contribute to the docs, please add inline comments to the code and then I'll get the docs updated. (#642).
-
Made
GraphQLResultError
and its underlying errorpublic
for better error handling. (#655)
- BREAKING: Removed internal
Result
type in favor of Swift's built inResult
type. This allows you to not have to prefix anything that uses the built-in result type withSwift.Result
in places where you're using the Apollo SDK. (#641) - BREAKING: Set strict dependency versions for Starscream and SQLite.swift to prevent potential problems with Swift version conflicts. (#641).
- BREAKING: Made Carthage dependencies for Starscream and SQLite.swift private so they're not automatically pulled in when trying to build just the main SDK with Carthage. If you're using the
ApolloSQLite
orApolloWebSocket
frameworks with Carthage, please read the updated documentation!. (#635, #641) - Fixed issue where
GET
requests were requiringAnyHashable
instead ofAny
which made requests withBool
properties never send. (#628, big thanks to #624)
- Fixed missing
Foundation
imports for several classes that were causing issues with Buck and Swift Package Manager builds. (#620) - Updated version of
SQLite.swift
dependency to one that properly supports Swift 5. (#621) - Whole mess o'documentation updates. (#618)
- Fixed a whitespace issue with one of the build scripts. (#618)
- Made the
GraphQLResult
initializer public for testing. (#544)
- BREAKING: Updated Podspec to preserve paths rather than embedding scripts in the framework. Updated instructions for embedding with CocoaPods. (#575, #610)
- NEW: At long last, the ability to update headers on preflight requests, the ability to peer into what came to the
URLSession
and the ability to determine if an operation should be retried. (#602) - NEW: Added
.fetchIgnoringCacheCompletely
caching option, which can result in significantly faster performance if you don't need the caching. (#551) - NEW: Added support for using
GET
for queries. (#572, #599, #602) - Updated lib and dependencies to use Swift 5, and say so in the Podfile. (#522, #528, #561, #592)
- Exposed a method to ping a WebSocket server to keep it alive. (#422)
- Handling is always done on a handler queue. (#539)
- Added documentation on the
read
andupdate
operations for watching queries. (#452) - Updated build scripts for non-CocoaPods installations to account for spaces in project names or folders. (#610)
- Fixed a code generation fail if you're using MacPorts instead of Homebrew to install
npm
. (#591)
- Disabled bitcode in Debug builds for physical devices (#499)
- Don't embed the Swift standard libraries by default (#501)
- Swift 5 support (#427, #475)
- Update to newest version of Starscream (#466
- Add ability to directly update cache with write methods (#413)
- Add docs for
read
andupdate
operations (#452)
- Add ability to pass params to
Query.Data
(#437) - Provide separate archs for the iOS Simulator (#410)
- Actually install the correct version of Node instead of just checking for it (#434)
- Updated required version of
apollo-cli
to1.9
. A nice addition to1.9.2
is that Swift Enums now conforms to Hashable enabling among other things comparison between fetch objects. (#578) - Fixed internal bug that caused infinite reconnection cycle when connection is lost. A reconnectionInterval was added as a workaround. (#368)
- Fixed internal bug that prevents the
wrongType
case being returned by theJSONDecodingError
implementation ofMatchable
. (#367) - Added delegate for WebTransport which can handle connection/reconnection/disconnection events of websocket. (#379)
- Since
apollo-codegen
is now part of the newapollo-cli
, the build script used to generateAPI.swift
needs to be updated. See the docs for the updated script.
-
Added read and write functions for fine-grained manual store updates.
-
Added support for pluggable asynchronous caches, with an optional experimental SQLite implementation.
-
Fragments are now merged into the parent result, so you only need to go through
fragments
when you want to pass a fragment explicitly. -
Generated result models are no longer immutable (but still obey value semantics).
-
Generated result models now have memberwise initializers (when they represent a concrete type) or type-specific factory methods (when they represent multiple possible types).
-
Any generated result model can be safely initialized from a JSON object (
init(jsonObject:)
and converted into ajsonObject
. -
Generated input objects now differentiate between a property being
null
and a property not being present.