Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/letoteteam/stardaze
A Swift GraphQL Tool
https://github.com/letoteteam/stardaze
graphql swift
Last synced: about 1 month ago
JSON representation
A Swift GraphQL Tool
- Host: GitHub
- URL: https://github.com/letoteteam/stardaze
- Owner: LeToteTeam
- License: mit
- Created: 2017-02-08T21:21:16.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-21T19:35:59.000Z (over 6 years ago)
- Last Synced: 2024-10-01T16:49:58.863Z (about 2 months ago)
- Topics: graphql, swift
- Language: Swift
- Size: 124 KB
- Stars: 10
- Watchers: 25
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stardaze
## A Swift GraphQL SerializerStardaze was born out of a need to create GraphQL queries in a typesafe way in Swift applications.
View the GraphQL spec [here](https://facebook.github.io/graphql).### Approaching this Library:
View the example playground for detailed usage examples. If you are unfamiliar with GraphQL, start by looking
at `Field`. From there, move on to `QueryOperation` and `Document`.### Example Usage:
``` swift
let productList = Field(name: "product_list", alias: "productList")
.appended(argument: Argument(key: "is_awesome", value: true))
.appended(argument: Argument(key: "color", value: Color.blue))
.appended(subFields: ["id", "title"])let queryOperation = QueryOperation(fields: [productList])
let document = Document(queryOperation: queryOperation)print(document.stringify(encoded: false))
// {
// productList: product_list(is_awesome: true, color: blue) {
// id
// title
// }
// }print(document.stringify(encoded: true))
// query=%7B%0A%09productList%3A%20product_list%28is_awesome%3A%20true%29%20%7B%0A%09%09id%0A%09%09title%0A%09%7D%0A%7Dlet parametersDictionary = document.parameterize(encoded: false)
print(parametersDictionary["query"])
// { productList: product_list(is_awesome: true) { id title } }```