Skip to content

Commit 5dbd1af

Browse files
committed
Initial commit of gqlgen work
1 parent fe44db7 commit 5dbd1af

File tree

18 files changed

+1158
-0
lines changed

18 files changed

+1158
-0
lines changed

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.1.0

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Build
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
11+
- uses: bazelbuild/setup-bazelisk@v2
12+
13+
- name: Mount bazel cache
14+
uses: actions/cache@v3
15+
with:
16+
path: "~/.cache/bazel"
17+
key: bazel
18+
19+
- run: bazel build //...

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bazel-bin
2+
bazel-out
3+
bazel-testlogs
4+
bazel-rules_gqlgen

BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
load("@bazel_gazelle//:def.bzl", "gazelle")
2+
3+
# gazelle:prefix github.com/Silicon-Ally/rules_gqlgen
4+
# gazelle:resolve go github.com/Silicon-Ally/rules_gqlgen/example/generated //example:gql_generated
5+
# gazelle:resolve go github.com/Silicon-Ally/rules_gqlgen/example/model //example:gql_model
6+
gazelle(name = "gazelle")
7+
8+
gazelle(
9+
name = "gazelle-update-repos",
10+
args = [
11+
"-from_file=go.mod",
12+
"-to_macro=deps.bzl%go_dependencies",
13+
"-prune",
14+
],
15+
command = "update-repos",
16+
)
17+
18+
exports_files([
19+
"go.mod",
20+
"go.sum",
21+
])

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
_This package brought to you by [Adventure
2+
Scientists](https://adventurescientists.org). Read more about [our open source
3+
policy here](https://siliconally.org/policies/open-source/)._
4+
5+
| :warning: WARNING |
6+
|:--------------------------------------------------|
7+
| `rules_gqlgen` is experimental, use with caution. |
8+
9+
# rules_gqlgen
10+
11+
`rules_gqlgen` provides Bazel rules for working with the
12+
[gqlgen](https://github.com/99designs/gqlgen) GraphQL server + codegen library.
13+
14+
## Usage
15+
16+
```bazel
17+
# In a BUILD.bazel
18+
19+
load("@com_siliconally_rules_gqlgen//gqlgen:def.bzl", "gqlgen")
20+
21+
# The below rule generated two library targets, :gql_generated and :gql_model,
22+
# which correspond to the auto-generated GraphQL glue code and model schema
23+
# types respectively.
24+
# The two generated rules would have import paths of
25+
# - github.com/Silicon-Ally/testproject/graph/generated, and
26+
# - github.com/Silicon-Ally/testproject/graph/model
27+
gqlgen(
28+
name = "gql",
29+
base_importpath = "github.com/Silicon-Ally/testproject/graph",
30+
schemas = ["//path/to:schema.graphqls"],
31+
visibility = ["//visibility:public"],
32+
)
33+
```
34+
35+
## Example
36+
37+
The `example` directory provides a basic GraphQL schema and server backed by
38+
`gqlgen`, you can run it with:
39+
40+
```bash
41+
bazel run //example
42+
```
43+
44+
The server will run on port 8080, you can access the playground at
45+
`http://localhost:8080/api/playground`, and try requests like:
46+
47+
```graphql
48+
# Query greetings
49+
{
50+
greetings {
51+
message
52+
lang
53+
}
54+
}
55+
56+
# Set a name
57+
mutation {
58+
updateName(req:{name:"Moxie"})
59+
}
60+
```

WORKSPACE

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
workspace(name = "com_siliconally_rules_gqlgen")
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
5+
http_archive(
6+
name = "io_bazel_rules_go",
7+
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
8+
urls = [
9+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
10+
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
11+
],
12+
)
13+
14+
http_archive(
15+
name = "bazel_gazelle",
16+
sha256 = "501deb3d5695ab658e82f6f6f549ba681ea3ca2a5fb7911154b5aa45596183fa",
17+
urls = [
18+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.26.0/bazel-gazelle-v0.26.0.tar.gz",
19+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.26.0/bazel-gazelle-v0.26.0.tar.gz",
20+
],
21+
)
22+
23+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
24+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
25+
load("//:deps.bzl", "go_dependencies")
26+
27+
# gazelle:repository_macro deps.bzl%go_dependencies
28+
go_dependencies()
29+
30+
go_rules_dependencies()
31+
32+
go_register_toolchains(version = "1.18.3")
33+
34+
gazelle_dependencies()
35+
36+
# Start of Stardoc configuration, see https://skydoc.bazel.build/ for more
37+
# details.
38+
http_archive(
39+
name = "io_bazel_stardoc",
40+
sha256 = "aa814dae0ac400bbab2e8881f9915c6f47c49664bf087c409a15f90438d2c23e",
41+
urls = [
42+
"https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.1/stardoc-0.5.1.tar.gz",
43+
"https://github.com/bazelbuild/stardoc/releases/download/0.5.1/stardoc-0.5.1.tar.gz",
44+
],
45+
)
46+
47+
load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")
48+
49+
stardoc_repositories()

0 commit comments

Comments
 (0)