📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
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.
This is the second preview release of @defer
support in Apollo iOS which focuses on providing early access to using the @defer
directive in your operations. During preview releases bugs can occur, if you do experience anything unexpected please report it to us.
Note: Apollo supports a very specific version of the @defer
directive proposal as documented here. The @defer
directive is still in the proposal stage and is not an official addition to the GraphQL specification yet. This means that Apollo iOS may not work with all servers that currently support @defer
.
@defer
directive then an error about duplicate directives would be thrown during code generation.We have a sample schema/server that supports @defer
and can be launched using the Docker configuration.
Once you have that service launched you can configure your Apollo iOS client to target the apollo-ios
and apollo-ios-codegen
dependency packages using the preview-defer.2
tag. Below is an example query using @defer
against the schema.
query ExampleQuery {
allProducts {
sku
id
... on Product @defer(label: "additional") {
dimensions {
size
}
variation {
id
name
}
}
}
}
Alternatively here is a sample client to demonstrate the code generation and operation execution of the @defer
directive.
Caveats in this preview release
@defer
.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).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.
Alongside the release of Apollo iOS 1.9.2, we are excited to announce the release of Apollo iOS Pagination! This package works alongside the Apollo iOS Client to make fetching and caching of paginated data a lot easier! Fetching paginated data has always been a pain point with our mobile clients, and an elegant solution for this has been a common feature request for many years. This library is feature rich and highly configurable, so we believe that it will be able to make this previously complex and difficult task a lot easier for our users!
This library supports:
This library is currently released as a 0.x version and is in active development. The API is subject to breaking changes until the stable 1.0 release. We hope that you will check it out and give us your feedback so that we can address any API improvements, edge cases, bugs, or valuable features we hadn’t considered before moving to a 1.0 release soon!
To learn more about Apollo iOS Pagination, see our usage docs.
ApolloClientProtocol
. Sorry about that! This patch release fixed the compatiblity. See PR #290. Thanks to @michaelloo for raising the issue.
URLSessionClient
(#286): The URLSessionClient
now allows you to set a sessionDescription
on the session and taskDescription
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 with self
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.
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.
@import(module:)
, on the defintion line, with a supplied String
as the module name will have that module used in a Swift import
statement at the top of the operation file and any referenced fragments. Thank you to @hemel for the contribution (#236 / #245).
fragmentDefinition
remains in all generated fragments when operationDocumentFormat
does not include .definition
(#3282): Code generation will now only generate definitions in fragment files if the operationDocumentFormat
config contains the .definition
value (#218). Thank you to @jimisaacs for raising the issue.
@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.swift-tools-version
to 5.9
, therefore Xcode 15 is now the minimum version of Xcode allowed.
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.
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.This is the first preview release of @defer
support in Apollo iOS which focuses on providing early access to using the @defer
directive in your operations. During preview releases bugs can occur, if you do experience anything unexpected please report it to us.
Note: Apollo supports a very specific early RFC version of the @defer
directive as documented here. The @defer
directive is still an RFC and is not an official addition to the GraphQL specification yet. This means that Apollo iOS may not work with all servers that currently support @defer
.
How to use it
We have a sample schema/server that supports @defer
and can be launched using the Docker configuration.
Once you have that service launched you can configure your Apollo iOS client to target the apollo-ios
and apollo-ios-codegen
dependency packages using the preview-defer.1
tag. Below is an example query using @defer
against the schema.
query ExampleQuery {
allProducts {
sku
id
... on Product @defer(label: "additional") {
dimensions {
size
}
variation {
id
name
}
}
}
}
Alternatively here is a sample client to demonstrate the code generation and operation execution of the @defer
directive.
Caveats in this preview release
@defer
.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.