Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/actionlint-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "actionlint",
"pattern": [
{
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)?:(?:\\x1b\\[\\d+m)?(\\d+)(?:\\x1b\\[\\d+m)?:(?:\\x1b\\[\\d+m)?(\\d+)(?:\\x1b\\[\\d+m)?: (?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)? \\[(.+?)\\]$",
"file": 1,
"line": 2,
"column": 3,
"message": 4,
"code": 5
}
]
}
]
}
26 changes: 26 additions & 0 deletions .github/workflows/lint-swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint Swift

on:
pull_request:
branches:
- '*'
paths:
- '**/*.swift'
- 'Package.swift'
- 'Package.resolved'
- '.swiftlint.yml'
- '.github/workflows/lint-swift.yml'

jobs:
swiftlint:
name: SwiftLint
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Install SwiftLint
run: brew install swiftlint

- name: Run SwiftLint
run: swiftlint lint --strict
30 changes: 30 additions & 0 deletions .github/workflows/lint-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint Workflows

on:
pull_request:
branches:
- '*'
paths:
- '.github/workflows/*.yml'
- '.github/actionlint-matcher.json'

jobs:
actionlint:
name: actionlint
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

- name: Download actionlint
id: get_actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
shell: bash

- name: Register problem matcher
run: echo "::add-matcher::.github/actionlint-matcher.json"

- name: Run actionlint
run: ${{ steps.get_actionlint.outputs.executable }} -color
shell: bash
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
push:
branches:
- main
paths:
- '**/*.swift'
- 'Package.swift'
- 'Package.resolved'
- '.github/workflows/test.yml'
pull_request:
branches:
- '*'
paths:
- '**/*.swift'
- 'Package.swift'
- 'Package.resolved'
- '.github/workflows/test.yml'

jobs:
macos:
name: macOS
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Swift version
run: swift --version

- name: Build
run: swift build -v

- name: Run tests
run: swift test -v
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let package = Package(
.target(
name: "GraphQLAPIKit",
dependencies: [
.product(name: "Apollo", package: "apollo-ios"),
.product(name: "Apollo", package: "apollo-ios")
]
),
.testTarget(
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Developed to simplify [Futured](https://www.futured.app) in-house development of

Currently there is no support for some Apollo's features:
- Apollo built-in cache
- GraphQL subscriptions
- Custom interceptors

Network observers are available for logging and analytics.
Expand Down Expand Up @@ -128,6 +127,25 @@ let queryResult = try await apiAdapter.fetch(query: query)
let mutationResult = try await apiAdapter.perform(mutation: mutation)
```

### Subscriptions
```swift
let subscriptionStream = try await apiAdapter.subscribe(subscription: MySubscription())

for try await data in subscriptionStream {
print("Received: \(data)")
}
```

### Deferred Responses (@defer)
```swift
let deferredStream = try apiAdapter.fetch(query: MyDeferredQuery())

for try await data in deferredStream {
// Data arrives progressively as deferred fragments complete
print("Received: \(data)")
}
```

## Contributors

- [Ievgen Samoilyk](https://github.com/samoilyk), <ievgen.samoilyk@futured.app>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,19 @@ public struct GraphQLRequestConfiguration: GraphQLOperationConfiguration {
self.headers = headers
}
}

/// Configuration for GraphQL subscriptions.
///
/// Use this struct to customize subscription-specific options.
/// Subscriptions are long-lived connections that may require different configuration than standard requests.
public struct GraphQLSubscriptionConfiguration: GraphQLOperationConfiguration {
/// Additional headers to add to the subscription request.
public let headers: RequestHeaders?

/// Creates a new subscription configuration.
///
/// - Parameter headers: Additional headers to add to the request. Defaults to `nil`.
public init(headers: RequestHeaders? = nil) {
self.headers = headers
}
}
Loading