0.4.0
#
Added- Generated result data types with an
id: String
property are now generated with a conformance toIdentifiable
, which makes them easier to use inList
andForEach
views. - Generated structs for
@connection
fields conform toRandomAccessCollection
if they include a selection ofedges { node { ... } }
. This means that you can replace something likedata.allFilms.edges.map { $0.node }
with justdata.allFilms
. See the @PaginationFragment docs for more info. - Generated query and mutation types now include some convenience extensions to make it easier to work with their variables:
- The initializer for the operation can take the variables directly instead of having to initialize a variables struct. For example, instead of
UserDetailsQuery(variables: .init(userID: "123"))
, you can writeUserDetailsQuery(userID: "123")
- The
get()
method on the wrapped value for theQueryNext
property wrapper (the beta version of @Query) can also take the query's variables directly. For example, instead ofquery.get(.init(userID: "123"))
, you can writequery.get(userID: "123")
- The initializer for the operation can take the variables directly instead of having to initialize a variables struct. For example, instead of
- The
QueryNext
property wrapper supports refetching queries by passing in afetchKey
parameter to theget()
method. Whenever the fetch key is changed from the last timeget()
was called, the query will be refetched. One way to use this is to have a@State
property for the fetch key and have your view change the value (a counter or UUID, perhaps) when it wants to refetch. - Queries can use two new fetch policies:
.storeOrNetwork
and.storeOnly
. The former avoids a network request if the data in the local store is complete and valid. The latter always skips the network, and expects the data to be present locally already. - The
RefetchableFragment
property wrapper has been added toRelaySwiftUI
. It supports fragments with a@refetchable
directive in their GraphQL definition. This wrapper is like an ordinary @Fragment but it includes arefetch()
method to refetch its data using a generated refetch query. RecordSource
now conforms toCodable
. This allows a store's records to be saved and loaded to disk, for instance. Until garbage collection is more configurable, this is probably of limited usefulness.
#
ChangedAll generated types and methods are now public (previously they had the default internal access). This makes it possible to keep your generated code in a different module like a SwiftPM package.
Matching
QueryNext
, theFragmentNext
andPaginationFragmentNext
property wrappers don't have a projected value anymore (accessed with the$
prefix). You must now set the key for a fragment property wrapper when it's initialized. This is closer to how Apple's own property wrappers, like@Binding
, work.To make this easier, types that conform to a fragment's
Key
protocol now also generateasFragment()
methods to create theFragmentNext
orPaginationFragmentNext
to pass on to a child view. Using this lets you avoid writing initializers for fragment views in many cases.
#
Fixed- The garbage collector will now only collect records on the final release of a query (instead of on every release).
- A retain cycle between RecordSourceProxy and its RecordProxy instances has been fixed.