Releases: apollographql/apollo-ios
1.15.2
Improvements
- Set
URLRequest
cache policy on GET requests (#476): Uses the Apollo cache policy to set a comparable cache policy onURLRequest
. Previously there was no way to opt-out of defaultURLRequest
caching behaviour. - Batch writing records to the SQLite store (#498): Uses the
insertMany
to batch write records for a given operation vs previously performing a write for each individual record.
Fixed
1.15.1
Fixed
- Fix decoding of deprecated
selectionSetInitializer
optionlocalCacheMutations
(#467): This option was deprecated in1.15.0
, and the removal of the code to parse the option resulted in a validation error when the deprecated option was present in the JSON code generation config file. This is now fixed so that the option is ignored but does not cause code generation to fail. - Disfavour deprecated watch function (#469): A deprecated version of the
watch
function matched the overload of the current version if certain parameters were omitted. This caused an incorrect deprecation warning in this situation. We've fixed this by adding@_disfavoredOverload
to the deprecated function signature.
1.15.0
New
- Add ability to disable fragment field merging (#431): Added
ApolloCodegenConfiguration
option to allow for disabling fragment field merging on generated models. For more information on this feature see the notes here.
Fixed
- Fix
legacyResponse
property not being set onHTTPResponse
(#456): When thelegacyResponse
property ofHTTPResponse
was deprecated setting the value was also removed; this was incorrect as it created a hidden breaking change for interceptors that might have been using the value. - Fix
ObjectData
type check (#459): Fixed bool type check inObjectData
. - Fix
SelectionSetTemplate
scope comparison (#460): Refactored the selection set template scope comparison to account for an edge case in merged sources. - Fix memory leak in DataLoader closure (#457): Fixed a memory leak in the DataLoader closure in
ApolloStore
caused by implicit use ofself
. Thank you to @prabhuamol for finding and fixing this.
Breaking
- Bug Fix: Generated Selections Sets in Inclusion Condition Scope: This fixes a bug when using @include/@Skip where generated models that should have been generated inside of a conditional inline fragment were generated outside of the conditional scope. This may cause breaking changes for a small number of users. Those breaking changes are considered a bug fix since accessing the conditional inline fragments outside of the conditional scope could cause runtime crashes (if the conditions for their inclusion were not met). More information here
1.14.1
New
- 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.
Fixed
- 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.
Preview: Codegen Field Merging
This is a preview release of a new feature that improves the code generation engine's field merging algorithm and allows for disabling of field merging altogether. The feature work for this preview version is being tracked in issue #2560.
Reduced Generated Code Size of Merged Selection Sets
The code generation algorithm is now able to recognize most situations where a merged selection set is a direct copy of a selection set that is being merged. In those cases, it now uses a typealias
referencing the original selection set rather than generating a duplicate. This is most commonly seen for the child entities of a named fragment that is spread into another selection set. In some cases this can dramatically decrease the size and complexity of the generated models.
Bug Fix: Generated Selections Sets in Inclusion Condition Scope
This also fixes a bug when using @include/@skip
where generated models that should have been generated inside of a conditional inline fragment were generated outside of the conditional scope. This may cause breaking changes for a small number of users. Those breaking changes are considered a bug fix since accessing the conditional inline fragments outside of the conditional scope could cause runtime crashes (if the conditions for their inclusion were not met).
Disabling Field Merging
If you need to further reduce the size of generated models, you can use the new experimental field merging configuration option to disable field merging.
The field merging feature has three types of merging that you can enable or disable selectively:
- Ancestors: Merges fields and fragment accessors from the selection set's direct ancestors.
- Siblings: Merges fields and fragment accessors from sibling inline fragments that match the selection set's scope.
- Named Fragments: Merges fields and fragment accessors from named fragments that have been spread into the selection set.
Limitations
Disabling of field merging is incompatible with the inclusion of selectionSetInitializers
. Because the generated initializers require fully formed objects with all field merged into them in order to ensure the generated objects are valid for each of their type cases. It is likely that this limitation will not be able to be resolved in the future. However we hope the new merging algorithm additions will provide enough of an improvement to the generated models to make disabling of field merging unnecessary for most users.
Configuration - JSON
To enable this option when using a json config file, use the configuration option experimentalFeatures.fieldMerging
.
{
"experimentalFeatures" : {
"fieldMerging" : [
# Any combination of these values:
"siblings",
"ancestors",
"namedFragments"
],
"legacySafelistingCompatibleOperations" : true
},
"input": {
# ...
You may also input fieldMerging: [ "all" ]
, to enable all types of field merging (which is the default value if not provided).
Configuration - Scripting with ApolloCodegenLib
To enable this option when using the ApolloCodegenLib
directly, set the ApolloCodegenConfiguration.experimentalFeatures.fieldMerging
option.
config = ApolloCodegenConfiguration(
schemaNamespace: "MySchema,
input: // ...,
output: // ...,
options: // ... ,
experimentalFeatures: .init(
fieldMerging: [
# Any combination of these values:
.siblings,
.ancestors,
.namedFragments
]
)
)
You may also input fieldMerging: .all
, to enable all types of field merging (which is the default value if not provided).
Known Issues
There is a longstanding bug (since Apollo iOS 1.0) in the codegen engine for some users that have large sets of operations with many deeply nested fragment spreads. For these users, the codegen engine never finishes running, using unbounded memory and eventually crashing once it has used all available memory. This version does not resolve this issue, but we are hoping to address this in a release in the near future!
Testing
Because the changes to the generated models in this version can be large in some circumstances, we would like to get feedback on any issues you encounter while using this preview version before we release this into a stable version of Apollo iOS. Please file an issue for any problems you encounter.
Issues may appear when using the new disabling of field merging, but we are also aware of possible issues when not using this new feature (ie. fieldMerging: .all
)
We are particularly concerned about possible issues in the following situations:
- GraphQL Definitions with deeply nested named fragments spreads
- Complex uses cases with
@include/@skip
conditions
In addition to feedback on problems you encounter, we would also love to hear about your success stories! If this new version works well for you and reduces the size of your generated models in a meaningful way, please let us know in #2560!
Thank you for trying out this preview version of Apollo iOS. We appreciate your time and effort as well as any feedback you can provide.
1.14.0
New
- 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.
Fixed
- 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.
1.13.0
New
- 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.
Fixed
- 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.
1.12.2
Fixed
- 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.
1.12.1
Fixed
- 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.
1.12.0
New
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.
Fixed
- 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.