Skip to content

Commit

Permalink
Corrected some syntax errors in my example code
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsky committed May 19, 2020
1 parent 699bafe commit 8eaed4c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
/.build
/Example/.build
/Packages
/*.xcodeproj
xcuserdata/
43 changes: 40 additions & 3 deletions Example/Sources/Example/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ 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
print(pipelines)
.sink(receiveCompletion: { _ in }) { pipelines in
print(pipelines)
}.store(in: &cancellables)
```

Expand Down Expand Up @@ -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 {
Expand All @@ -108,16 +108,16 @@ struct MyPipeline: Codable {
var cancellables: Set<AnyCancellable> = []
client.sendPublisher(GraphQL<MyPipeline>(rawQuery: query, variables: ["first": 30]))
.map(\.content)
.sink(recieveCompletion: { _ in }) { pipelines in
print(pipelines)
.sink(receiveCompletion: { _ in }) { pipelines in
print(pipelines)
}.store(in: &cancellables)
```

## References

- [Buildkite](https://buildkite.com/)
- [Buildkite API Documentation](https://buildkite.com/docs/apis)
- [Buildkite GraphQL Explorer](https://graphql.buildkite.com/explorer)
- [Buildkite](https://buildkite.com/)
- [Buildkite API Documentation](https://buildkite.com/docs/apis)
- [Buildkite GraphQL Explorer](https://graphql.buildkite.com/explorer)

## License

Expand Down

0 comments on commit 8eaed4c

Please sign in to comment.