0.3.0

Added#

  • A MockEnvironment is now available to allow for writing tests or SwiftUI previews

  • The default ConnectionHandler has new methods that can be used to update paged result sets in an updater function of a mutation. See the ConnectionHandler docs to learn more.

  • Records in the Relay store that are no longer referenced by a visible view will be garbage-collected to free up memory

  • @Mutation's commit function now takes an onComplete block that will be called once the network has completed the mutation

  • All four SwiftUI property wrappers now have an experimental Next variant (e.g. QueryNext) that's only available on iOS 14 or later (and equivalent versions of other Apple platforms). These versions use the new @StateObject wrapper to let SwiftUI manage the storage of their internal state and tie it to the lifetime of the view. This is more correct than the existing property wrappers, which can sometimes get recreated unnecessarily when other view state changes.

    The API for these new wrappers is experimental and may change. In some future release after these platform versions are no longer in beta, support for iOS 13 will be dropped and these new wrappers will replace the existing ones.

    If you're targeting a minimum of iOS 14 (or equivalent), you can use the new wrappers in your app. You may find it handy to make type aliases to the existing names (which will override the names imported from RelaySwiftUI):

import RelaySwiftUI
typealias Fragment = RelaySwiftUI.FragmentNext
typealias PaginationFragment = RelaySwiftUI.PaginationFragmentNext
typealias Query = RelaySwiftUI.QueryNext
typealias Mutation = RelaySwiftUI.MutationNext

Changed#

  • The Swift types generated for reading fragment data now implement Swift's Decodable protocol rather than a custom Readable protocol. The Relay compiler no longer needs to generate init(from: SelectorData) methods for all of these types, and in many cases can rely on Swift itself to synthesize an implementation for init(from: Decoder).

Fixed#

  • Union and interface types can be used and will generate appropriate Swift types
  • optimisticUpdater and updater functions are now supported in mutations. Previously, they could be passed in but they did nothing.
  • The errors in a GraphQL response payload are processed and handled correctly.