Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsky committed May 19, 2020
1 parent 135510d commit 699bafe
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Build Status](https://github.com/aaronsky/buildkite-swift/workflows/CI/badge.svg)

A Swift library and client for the Buildkite REST API.
A Swift library and client for the Buildkite REST and GraphQL APIs.

## Usage

Expand All @@ -12,7 +12,7 @@ Add the dependency to your `Package.swift` file:
let package = Package(
name: "myproject",
dependencies: [
.package(url: "https://github.com/aaronsky/buildkite-swift.git", from: "0.0.1"),
.package(url: "https://github.com/aaronsky/buildkite-swift.git", from: "0.0.3"),
],
targets: [
.target(
Expand Down Expand Up @@ -58,10 +58,66 @@ client.sendPublisher(Pipeline.Resources.List(organization: "buildkite"))

The entire publicly documented REST API surface is supported by this package.

### GraphQL

GraphQL support is present, but currently rudimentary. For example, here's what the same query as above would look like in GraphQL:

```swift
import Foundation
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 Organizations: 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(GraphQL<MyPipeline>(rawQuery: query, variables: ["first": 30]))
.map(\.content)
.sink(recieveCompletion: { _ in }) { pipelines in
print(pipelines)
}.store(in: &cancellables)
```

## References

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

## License

Expand Down

0 comments on commit 699bafe

Please sign in to comment.