Swiftpack.co - Package - tuoitrevohoc/FetchQL

FetchQL

A Simple GraphQL Client using Combine Framework

Execute a query:

let fetchQL = FetchQL(endPoint: "https://.....")
let query = """
query GetTodo($id: String!) {
    getTodo(id: $id) {
        name
        description
    }
}
"""

let anyCancellable = fetchQL.query(query, variables: ["id": "1"], for: Todo.self)
    .sync(receiveCompletion: { completion in
        print("\(completion)")
    }, receiveValue: { todo in
        printf("\(result.getTodo)")
    })

Subscribe to a subscription

let fetchQL = FetchQL(endPoint: "https://....")
let subscriptionQuery = """
subscription OnTodoCreated() {
    onTodoCreated() {
        name
        description
    }
}
"""

let anyCancellable = fetchQL.subscribe(subscriptionQuery, variables: [], for: Todo.self)
    .sync(receiveCompletion: { completion in
        print("\(completion)")
    }, receiveValue: { todo in
        printf("\(result.onTodoCreated)")
    })

Use an API Key

let fetchQL = FetchQL(endPoint: "....", plugin: ApiKeyPlugin(apiKey: "..."))

Use with AppSync

let fetchQL = FetchQL(endPoint: "....", plugin: AppSyncPlugin(apiKey: "..."))

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

Fix bug unwrapped value - 2020-05-13 19:12:31

First version of FetchQL - 2020-05-13 19:02:25

Need to check Memory Leak around web socket client if any.