This package was developed by Silicon Ally while working on a project for Adventure Scientists. Many thanks to Adventure Scientists for supporting our open source mission!
NOTE: this package currently fetches dependencies over the internet, rather than using the local ones already present in your Bazel WORKSPACE. This is suboptimal, and may cause discrepancies if not carefully managed. We're hoping to fix it long term.
rules_gqlgen
provides bazel rules that allow you to
build GraphQL Servers in Go.
Under the hood, it generates a Go runtime + model using the gqlgen GraphQL server + codegen library.
# In a BUILD.bazel file
load("@com_siliconally_rules_gqlgen//gqlgen:def.bzl", "gqlgen")
# The rule below generates two library targets, :gql_generated and :gql_model,
# which correspond to the auto-generated GraphQL glue code and model schema
# types respectively.
# The two generated rules would have import paths of
# - github.com/Silicon-Ally/testproject/graph/generated, and
# - github.com/Silicon-Ally/testproject/graph/model
gqlgen(
name = "gql",
base_importpath = "github.com/Silicon-Ally/testproject/graph",
schemas = ["//path/to:schema.graphqls"],
visibility = ["//visibility:public"],
)
The example
directory provides a basic GraphQL schema and server backed by
gqlgen
, you can run it with:
# example/ is a separate Bazel workspace, so need to enter it first.
cd example
# Run the server on port 8080
bazel run //:example
See the the example's README.md for a thorough explanation of what is happening.
Currently, rules_gqlgen
does not support the gqlgen configuration file,
gqlgen.yml
file, beyond specifying the schema to generate code for. If this
is important to you, or you have specific features in mind that you'd like
supported, file an issue.
Contribution guidelines can be found on our website.