52
loading...
This website collects cookies to deliver better user experience
This article was published on 2021-08-02 by Matic Zavadlal @ The Guild Blog
type Query {
humans: [Human!]!
}
type Human {
id: ID!
name: String!
home: String
}
struct Person {
var id: String
var name: String
}
Selection.
followed by the name of the type that we want to use to make a selection. In our case, that would be Selection.Human
.let human = Selection.Human {
Person(
id: try $0.id(),
name: try $0.name()
)
}
send
method.let query = Selection.Query {
$0.human(id: "1000", selection: human)
}
send(query, to: "https://swapi.graphql.com") { result in
if let data = try? result.get() {
print(data.human)
}
}
brew install swift-graphql
,swift-graphql <endpoint> --output ./file.swift
,