All Projects → florianmari → LiveGQL

florianmari / LiveGQL

Licence: MIT license
Use GraphQL Subscriptions on iOS 👌

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
Makefile
30231 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to LiveGQL

36 Graphql Concepts
📜 36 concepts every GraphQL developer should know.
Stars: ✭ 209 (+148.81%)
Mutual labels:  graphql-client, graphql-subscriptions
kobby
Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Stars: ✭ 52 (-38.1%)
Mutual labels:  graphql-client, graphql-subscriptions
py-graphql-client
Dead-simple GraphQL client with subscriptions over websockets
Stars: ✭ 36 (-57.14%)
Mutual labels:  graphql-client, graphql-subscriptions
Morpheus Graphql
Haskell GraphQL Api, Client and Tools
Stars: ✭ 285 (+239.29%)
Mutual labels:  graphql-client, graphql-subscriptions
Aws Mobile Appsync Sdk Js
JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Stars: ✭ 806 (+859.52%)
Mutual labels:  graphql-client, graphql-subscriptions
Altair
✨⚡️ A beautiful feature-rich GraphQL Client for all platforms.
Stars: ✭ 3,827 (+4455.95%)
Mutual labels:  graphql-client, graphql-subscriptions
soyuz
Real-time streaming GraphQL client for the web.
Stars: ✭ 57 (-32.14%)
Mutual labels:  graphql-client, graphql-subscriptions
Kikstart Graphql Client
🚀 Small NodeJS Wrapper around apollo-client that provides easy access to running queries, mutations and subscriptions.
Stars: ✭ 27 (-67.86%)
Mutual labels:  graphql-client, graphql-subscriptions
Aws Mobile Appsync Sdk Ios
iOS SDK for AWS AppSync.
Stars: ✭ 231 (+175%)
Mutual labels:  graphql-client, graphql-subscriptions
StarWars
Minimal GraphQL based Jetpack Compose, Wear Compose and SwiftUI Kotlin Multiplatform sample (using StarWars endpoint - https://graphql.org/swapi-graphql)
Stars: ✭ 165 (+96.43%)
Mutual labels:  graphql-client
serverless-graphql-subscriptions
Graphql subscriptions with apollo-server-lambda
Stars: ✭ 67 (-20.24%)
Mutual labels:  graphql-subscriptions
artemis
Ruby GraphQL client on Rails that actually makes you more productive
Stars: ✭ 149 (+77.38%)
Mutual labels:  graphql-client
flutter-graphql
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package. Built after react apollo
Stars: ✭ 45 (-46.43%)
Mutual labels:  graphql-client
nextjs-typescript-postgresql-graphql-realtime-chat
WunderGraph Realtime Chat Example using NextJS, TypeScript, PostgreSQL, GraphQL
Stars: ✭ 53 (-36.9%)
Mutual labels:  graphql-subscriptions
nextjs-graphql-auth
Authentication system using NextJS, GraphQL, Apollo Client, Apollo Server, MongoDB, Nginx, Docker, Docker-Compose and Kubernetes
Stars: ✭ 27 (-67.86%)
Mutual labels:  graphql-subscriptions
nim-graphql
Nim implementation of GraphQL with sugar and steroids
Stars: ✭ 47 (-44.05%)
Mutual labels:  graphql-client
gatsby-starter-redux-saas
An Gatsby starter for Saas products. Uses redux and apollo and a graphql token auth backend.
Stars: ✭ 18 (-78.57%)
Mutual labels:  graphql-client
DotNetGraphQL
A sample demonstrating how to create a GraphQL Backend in .NET and consume it from a .NET mobile app created using Xamarin
Stars: ✭ 78 (-7.14%)
Mutual labels:  graphql-client
protoc-gen-twirpql
Generate A GraphQL Layer from A Twirp Server: https://twirpql.dev
Stars: ✭ 49 (-41.67%)
Mutual labels:  graphql-client
vue-gql
A small and fast GraphQL client for Vue.js
Stars: ✭ 32 (-61.9%)
Mutual labels:  graphql-client

LiveGQL: Use GraphQL Websocket subscription in Swift

Carthage compatible CocoaPod GraphQL

LiveGQL is a simple library to use GraphQL Subscribtion on WebSocket based on Apollo Protocol.

The Android version is here

Features

  • Connect to a GraphQL WebSocket server
  • Send messages
  • Subscribe / unsubscribe
  • Close connection
  • Data handling (delegate)
  • Error handling
  • Reconnect option
  • JSON raw response
  • Queue of unsent messages
  • Implement all Apollo protocol
  • Specify entry protocol

Requirements

  • iOS / tvOS >= 9.0
  • Xcode >= 8.1
  • Swift >= 3.0

We also use SocketRocket and JSONCodable, thanks to them

Communication

  • Use issue if you have any problem
  • Don't hesitate to contribute to the project with a pull request

Installation

CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'LiveGQL', '~> 2.0.0'
end

Carthage

github "florianmari/LiveGQL"

See Carthage guide for more informations about integrating with Carthage.

Manually

Just copy files in the Source folder!

Usage

Initializing

Important: to not fall out the variable in the scope, please instantiate above your viewDidLoad() for example.

import LiveGQL

let gql = LiveGQL(socket: "ws://localhost:7003/feedback")

gql.delegate = self
gql.initServer(connectionParams: nil, reconnect: true)

You can set a Dictionnary[String:String] as connectionParams like for authentification by example. The default protocol is now: graphql-subscriptions, but you can specify yours this way

import LiveGQL
let gql = LiveGQL(socket: "ws://localhost:7003/feedback", protocol: "graphql-subscriptions")

Subscribe / Unsubscribe

Subscribe

Just call subscribe method, set an identifier and your subscription query as well.

gql.subscribe(graphql: "subscription {feedbackAdded {id, text}}", identifier: "feed")

These parameters are mandatory but you can specify exposed variables and operation names if you want, look at the signature:

public func subscribe(graphql query: String, variables: [String: String]?, operationName: String?, identifier: String) {}
Treat server response

You have to implement delegate method, in your main ViewController (for example) just att that

override func viewDidLoad() {
        super.viewDidLoad()
        gql.delegate = self
        // Do any additional setup after loading the view, typically from a nib.
    }

Below your class add the folowing extension and implement the method:

extension ViewController: LiveGQLDelegate {
    func receivedMessage(text: String) {
        print("Received Message: \(text)")
    }
}

Unsubscribe

Just call unsubscribe method and your identifier

gql.unsubscribe(identifier: "feed")

Close connection

gql.closeConnection()

What's new?

2.0.0

In this second version of LiveGQL, we give up Starscream for using SocketRocket from Facebook, as well, the protocol has been fixed and you can specify yours!

Contributors

I'd like to thanks these people for their contributions:

[@rhishikeshj] for cleaning the code and implement SocketRocket! [@duncsand] for adding exposed variables and operationName on subscription call [@josefdolezal] for giving us Carthage support!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].