Swiftpack.co -  Saelyria/Artemis as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Write GraphQL queries like SwiftUI views - no strings, no dictionaries.
.package(url: "https://github.com/Saelyria/Artemis.git", from: "0.0.1")


Build status Platform iOS Swift 5.3 compatible License: MIT

Artemis is a GraphQL library for Swift that lets you interact with a GraphQL backend entirely in Swift - no unsafe queries made of strings, no Data or [String: Any] responses you need to parse though manually. Artemis uses KeyPath objects to keep track of types used in queries, so this request:

// Artemis                                  // Rendered GraphQL query
Operation(.query) {                         query {
    Add(\.country, alias: "canada") {           canada: country(code: "CA") {
        Add(\.name)                                 name
        Add(\.continent) {                          continent {
            Add(\.name)                                 name
        }                                           }
    }.code("CA")                                }
}                                           }

...results in a Partial<Country> object that you can interact with using the same keypaths and type inference as a normal Country instance. Artemis will populate the response object with the fetched data - so this query (and its response) are handled like this:

let client = Client<Query>()

client.perform(query) { result in
    switch result {
    case .success(let country):
        country.name // "Canada"
        country.continent?.name // "North America"
        country.languages // nil
    case .failure(let error):
        // error handling

Don't let this simple example sell Artemis short, though - it includes full support for fragments, arguments, mutations, multiple query fields, and code generation from GraphQL schema documents so you can get up and running with a new API in minutes. It's also very light (requiring only Foundation), so supports iOS, macOS, or anywhere else Swift and Foundation can run.

For instructions on adding Artemis to your project and setting up code generation, check out the installation and setup guide.

Once you're setup, you can check out the tutorial on getting started with Artemis guide to get up and running with making requests.


Aaron Bosnjak (email: aaron.bosnjak707@gmail.com, Twitter: @aaron_bosnjak)

Artemis is open to contributors! If you have a feature idea or a bug fix, feel free to open a pull request. Issues and feature ideas are tracked on this Trello board.


Artemis is available under the MIT license, so do pretty much anything you want with it. As always, see the LICENSE file for more info.


Stars: 51
Last commit: 6 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.

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