Swiftpack.co -  GraphQLSwift/GraphQLRxSwift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
GraphQLSwift/GraphQLRxSwift
The Swift GraphQL RxSwift subscription driver
.package(url: "https://github.com/GraphQLSwift/GraphQLRxSwift.git", from: "0.0.3")

GraphQLRxSwift

GraphQLRxSwift is a small Swift GraphQL/Graphiti subscription driver that allows usage of RxSwift observables as subscription event streams.

Swift License

Looking for help? Find resources from the community.

Getting Started

Before using, it is best to familiarize yourself with the Swift GraphQL and Graphiti packages.

Usage

Add GraphQLRxSwift to your Package.swift

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/GraphQLSwift/GraphQLRxSwift.git", .upToNextMinor(from: "0.0.1")),
    ]
)

GraphQLRxSwift provides an ObservableEventStream wrapper class that can be used with an RxSwift Observable to satisfy EventStream requirements. A convenience method toEventStream is added to all Observable instances. This class is used when defining subscription resolvers, as shown below:

func subscribeUser(context: HelloContext, arguments: NoArguments) -> EventStream<Any> {
    PublishSubject<Any>().toEventStream()
}

Also provided is a ObservableSubscriptionEventStream type alias that can be used to downcast the result of a subscribe execution. It is guaranteed that the stream returned by any subscription query whose resolver returns an ObservableEventStream will be a ObservableSubscriptionEventStream. For example:

let subscriptionResult = try graphQLApi.subscribe(
    request: request,
    context: api.context,
    on: group
).wait()
let subscription = subscriptionResult.stream as! ObservableSubscriptionEventStream? // Guaranteed

License

This project is released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 3
Last commit: 3 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

0.0.3 - Fresh Cut Grass
3 days ago
  • Corrects test field ordering
  • Updates GraphQL dependency to new major

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API