Skip to content

Commit 0950aa7

Browse files
Merge pull request #2 from NeedleInAJayStack/examples/star-wars
Adds real StarWars example
2 parents 6e938f1 + 659d83b commit 0950aa7

19 files changed

Lines changed: 1641 additions & 103 deletions

File tree

Examples/GraphQLDotOrg/Package.resolved

Lines changed: 0 additions & 33 deletions
This file was deleted.

Examples/GraphQLDotOrg/Package.swift

Lines changed: 0 additions & 32 deletions
This file was deleted.

Examples/GraphQLDotOrg/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

Examples/GraphQLDotOrg/Sources/GraphQLDotOrg/GraphQLDotOrg.swift

Lines changed: 0 additions & 11 deletions
This file was deleted.

Examples/StarWars/Package.resolved

Lines changed: 231 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/StarWars/Package.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// swift-tools-version: 6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "StarWars",
7+
platforms: [
8+
.macOS(.v13),
9+
],
10+
products: [
11+
.library(
12+
name: "StarWars",
13+
targets: ["StarWars"]
14+
),
15+
],
16+
dependencies: [
17+
.package(name: "graphql-generator", path: "../.."),
18+
.package(url: "https://github.com/GraphQLSwift/DataLoader", from: "2.0.0"),
19+
.package(url: "https://github.com/GraphQLSwift/GraphQL", from: "4.1.0"),
20+
.package(url: "https://github.com/swift-server/async-http-client", from: "1.0.0"),
21+
],
22+
targets: [
23+
.target(
24+
name: "StarWars",
25+
dependencies: [
26+
.product(name: "AsyncDataLoader", package: "DataLoader"),
27+
.product(name: "AsyncHTTPClient", package: "async-http-client"),
28+
.product(name: "GraphQL", package: "GraphQL"),
29+
.product(name: "GraphQLGeneratorRuntime", package: "graphql-generator"),
30+
],
31+
plugins: [
32+
.plugin(name: "GraphQLGeneratorPlugin", package: "graphql-generator"),
33+
]
34+
),
35+
.testTarget(
36+
name: "StarWarsTests",
37+
dependencies: [
38+
"StarWars",
39+
]
40+
),
41+
]
42+
)

Examples/StarWars/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Star Wars
2+
3+
This is a `graphql-generator` example using the schema at https://graphql.org/graphql/, which wraps the [Star Wars API](https://www.swapi.tech) (SWAPI). For a Javascript implementation, see https://github.com/graphql/swapi-graphql
4+
5+
It uses [async-http-client](https://github.com/swift-server/async-http-client) to make the web requests and a [DataLoader](https://github.com/GraphQLSwift/DataLoader) to cache SWAPI responses.
6+
7+
## Getting Started
8+
9+
To get started, simply open this directory and build the project:
10+
11+
```swift
12+
swift build
13+
```
14+
15+
Running the tests will print some example query responses to the console.

0 commit comments

Comments
 (0)