Corrected some syntax errors in my example code

This commit is contained in:
Aaron Sky 2020-05-19 09:09:29 -04:00
parent 699bafe828
commit 8eaed4c74f
3 changed files with 49 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.DS_Store
/.build
/Example/.build
/Packages
/*.xcodeproj
xcuserdata/

View File

@ -11,16 +11,53 @@ import Buildkite
let client = Buildkite()
client.token = "..."
let query = """
query MyPipelines($first: Int!) {
organization(slug: "buildkite") {
pipelines(first: $first) {
edges {
node {
name
uuid
}
}
}
}
}
"""
struct MyPipeline: Codable {
var organization: Organization?
struct Organization: Codable {
var pipelines: Pipelines
struct Pipelines: Codable {
var edges: [PipelineEdge]
struct PipelineEdge: Codable {
var node: Pipeline
struct Pipeline: Codable {
var name: String
var uuid: UUID
}
}
}
}
}
var cancellables: Set<AnyCancellable> = []
client.sendPublisher(Build.Resources.Get(organization: "wayfair", pipeline: "merge-train-ci", build: 162))
client.sendPublisher(GraphQL<MyPipeline>(rawQuery: query, variables: ["first": 30]))
.map(\.content)
.sink(receiveCompletion: { result in
if case let .failure(error) = result {
print(error)
exit(1)
}
}) { agents in
print(agents)
}) { pipelines in
print(pipelines)
exit(0)
}.store(in: &cancellables)

View File

@ -51,7 +51,7 @@ client.token = "..." // Your scoped Buildkite API access token
var cancellables: Set<AnyCancellable> = []
client.sendPublisher(Pipeline.Resources.List(organization: "buildkite"))
.map(\.content)
.sink(recieveCompletion: { _ in }) { pipelines in
.sink(receiveCompletion: { _ in }) { pipelines in
print(pipelines)
}.store(in: &cancellables)
```
@ -87,7 +87,7 @@ query MyPipelines($first: Int!) {
struct MyPipeline: Codable {
var organization: Organization?
struct Organizations: Codable {
struct Organization: Codable {
var pipelines: Pipelines
struct Pipelines: Codable {
@ -108,7 +108,7 @@ struct MyPipeline: Codable {
var cancellables: Set<AnyCancellable> = []
client.sendPublisher(GraphQL<MyPipeline>(rawQuery: query, variables: ["first": 30]))
.map(\.content)
.sink(recieveCompletion: { _ in }) { pipelines in
.sink(receiveCompletion: { _ in }) { pipelines in
print(pipelines)
}.store(in: &cancellables)
```