Releases: apollographql/apollo-ios
1.18.0
New
- Reduce Generated Schema Types (#3505): Adds a new codegen configuration option to reduce the number of
Objecttypes that are generated so that only types that are referenced in an operation document or have a@typePolicywill be generated. See PR #601.
Improvement
- Identifiable conformance for named fragments (#595): Identifiable conformance was previously implemented (#584) for selection sets and has now been extended to include named fragments. Thank you to @x-sheep for the contribution.
Fixed
- Accessing an unset deprecated field in input causes a crash (#3506):
InputObjectneeded aGraphQLNullable-specific subscript to prevent nil value keys being forcefully unwrapped. See PR #596. Thank you to @pixelmatrix for raising the issue. - Crash in
WebSocketTransportdue to data races (#3512): This data race would occur if starting or stopping a subscription at the same time as a message received on the websocket. To prevent these data races thesubscribersproperty is now an@Atomicproperty. See PR #599. Thank you to @tahirmt for the contribution.
1.17.0
New
- Add suffix to schema type filenames (#2598): When fragments were named the same as schema types code generation would produce two files with the same name, but at different paths, for each respective type. This would cause a build error in Xcode. There is a new codegen configuration option (
appendSchemaTypeFilenameSuffix) to add a suffix to schema generated filenames and prevent the build error. See PR #580. - Specify caching fields with
typePolicydirective (#554): The@typePolicydirective lets you specify an object's cache ID using key fields of the response object. See the documentation for full details. Thank you to @x-sheep for the contribution. - Emit
Identifiableconformance onSelectionSet(#584): If the@typePolicyof a type uses akeyFieldofidthe selection set will emit conformance to SwiftsIdentifiableprotocol. Thank you to @x-sheep for the contribution.
Improvement
- Improved performance of code generation on operations with many nested fragments (#3434): When fragment field merging is disabled the fragment selection trees are no longer merged into the
EntitySelectionSetwhile building operations. See PR #571.
Fixed
- Defer metadata extension (#3505): Metadata extensions for deferred selection sets were incorrectly generated inside the namespace extension for
embeddedInTargetandothermodule types. See PR #581. DataDictinitialization ofdeferredFragmentsfor named fragments (#587): When deferred fragments are named fragments the deferred type should be the fragment generated definition name.
1.16.1
1.16.0
New
- Added codegen config support for spm module type versions (#539): There is a new codegen config option for supplying a version to the SPM module type to allow for pointing to specific branches or local versions of Apollo iOS.
@oneOfinput object support (#537): Adding support for@OneOfInput Objects, more info can be found in the official RFC.
Improvements
URLRequestcache policy default changed (#550): The updated default closer matches the original behaviour before the introduction of settingURLRequest.CachePolicy. Thank you to @marksvend for raising the issue.
Fixed
DataDictinitialization ofdeferredFragmentsproperty (#557): Generated selection set initializers were not correctly setting deferred fragment identifiers. This only affected selection sets that were instantiated with the generated selection set initializers, response-based results are unaffected.- Multipart chunk content type (#572): Multipart response parsing would produce an error when the chunk content type contained more than one directive. Thank you to @brettephillips for raising the issue.
1.15.3
Improvements
Fixed
- Fix multipart delimter boundary parsing (#502): The multipart message parsing code was not splitting message chunks at the correct boundary.
- Fix Websocket error broadcast for unsubscribed ID (#506) Only broadcast an error to all subscribers if there was no id field in the message.
- Fix bug with
AnyHashablecoercion for non-iOS platforms (#517): Extended the _AnyHashableCanBeCoerced check to include macOS, watchOS, and tvOS with their respective minimum versions. Thank you to @VMLe for the fix. - Fix assigning websocket callback queue before connecting (#529): Fix an issue with assigning the websocket callback queue before connecting the websocket.
- Fix
GraphQLOperationhash uniqueness (#530): Adding uniqueness to GraphQLOperation hashing.
1.15.2
Improvements
- Set
URLRequestcache 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 defaultURLRequestcaching behaviour. - Batch writing records to the SQLite store (#498): Uses the
insertManyto 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
selectionSetInitializeroptionlocalCacheMutations(#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
watchfunction 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@_disfavoredOverloadto the deprecated function signature.
1.15.0
New
- Add ability to disable fragment field merging (#431): Added
ApolloCodegenConfigurationoption to allow for disabling fragment field merging on generated models. For more information on this feature see the notes here.
Fixed
- Fix
legacyResponseproperty not being set onHTTPResponse(#456): When thelegacyResponseproperty ofHTTPResponsewas 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
ObjectDatatype check (#459): Fixed bool type check inObjectData. - Fix
SelectionSetTemplatescope 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
ApolloStorecaused 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
GraphQLErroris “too many validation errors”" (#438): When a GraphQLError from the JS parsing step is a “Too many validation errors” error, there is nosourcein 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
@deferdirective 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 anerrorsonly GraphQL response. - Avoid using
fatalErroronJSONEncodable(#128): The fatal error logic inJSONEncodablewas replaced with a type constraintwhereclause. Thank you to @arnauddorgans for the contribution. - Introspection-based schema download creates duplicate
@deferdirective definition (#3417): The codegen engine can now correctly detect pre-existing@deferdirective 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/@skipconditions
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.