Giter VIP home page Giter VIP logo

swift-graphql's Introduction

A GraphQL client that lets you forget about GraphQL.

CI Tests

Features

  • โœจ Intuitive: You'll forget about the GraphQL layer altogether.
  • ๐Ÿ– Time Saving: I've built it so you don't have to waste your precious time.
  • โ˜๏ธ Generate once: Only when your schema changes.
  • โ˜Ž๏ธ Subscriptions: Listen to subscriptions using webhooks.
  • ๐Ÿ” High Level: You don't have to worry about naming collisions, variables, anything. Just Swift.

Overview

SwiftGraphQL is a Swift code generator and a lightweight GraphQL client. It lets you create queries using Swift, and guarantees that every query you create is valid.

The library is centered around three core principles:

  • ๐Ÿš€ If your project compiles, your queries work.
  • ๐Ÿฆ‰ Use Swift in favour of GraphQL wherever possible.
  • ๐ŸŒณ Your application model should be independent of your schema.

Here's a short preview of the SwiftGraphQL code

import SwiftGraphQL

// Define a Swift model.
struct Human: Identifiable {
    let id: String
    let name: String
    let homePlanet: String?
}

// Create a selection.
let human = Selection.Human {
    Human(
        id: try $0.id(),
        name: try $0.name(),
        homePlanet: try $0.homePlanet()
    )
}

// Construct a query.
let query = Selection.Query {
    try $0.humans(human.list)
}

// Perform the query.
send(query, to: "http://swift-graphql.heroku.com") { result in
    if let data = try? result.get() {
        print(data) // [Human]
    }
}

Documentation

You can find detailed documentation on the SwiftGraphQL page at swift-graphql.vercel.app


Roadmap and Contributing

This library is feature complete for our use case. We are actively using it in our production applications and plan to expand it as our needs change. We'll also publish performance updates and bug fixes that we find.

I plan to actively maintain it for many upcoming years. Swift seems like a fantastic language and I've only started learning it.

Feel free to create a pull request with future improvements. Please, document your contributions well, and clearly outline the benefits of the change. It's also very helpful to include the ideas behind changes.

Here's a rough collection of ideas we might tackle next:

  • Networking Layer
  • Caching

PS.: PRs for the above features will be reviewed a lot more quickly!

Thank you

I want to dedicate this last section to everyone who helped me along the way.

  • First, I would like to thank Dillon Kearns, the author of elm-graphql, who inspired me to write the library, and helped me understand the core principles behind his Elm version.
  • Second, I would like to thank Peter Albert for giving me a chance to build this library, having faith that it's possible, and all the conversations that helped me push through the difficult parts of it.
  • Lastly, I'd like to thank every contributor to the project. SwiftGraphQL is better because of you. Thank you!

Thank you! ๐Ÿ™Œ


License

MIT @ Matic Zavadlal

swift-graphql's People

Contributors

maticzav avatar amzd avatar galvingao avatar idiomatic avatar pabloszx avatar marmarelis avatar codifilo avatar barnard-b avatar cooperwolfe avatar dato avatar singingwolfboy avatar fedos avatar keuha avatar lromyl avatar tamc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.