rules_graphql
v0.1.3
published 11 hours ago
3 stars
0 forks
0 watchers
MIT License
public
4 assets
65 downloads
35 KB
Compatibility level 1
e7iAKr8M4NkfCVqvTWdQr5zAsP2Zq0Hp5VOhcpljnZA=
Maintained byHunter John Larco
v0.1.3
September 29, 2025
[expand for release notes]

Bazel rules for GraphQL

This ruleset is a Bazel integration for GraphQL, based on the excellent tools provided by The Guild.

rules_graphql is just one part of the wider bazel ecosystem. For additional build rules we suggest visiting with Bazel Central Registry or consider Aspect's robust monorepo developer platform:

Installation

Follow instructions from the release you wish to use: https://github.com/HunterLarco/rules_graphql/releases.

Usage

See the documentation in the docs folder.

Examples

Basic usage examples can be found under the examples folder.

Note that the examples also rely on code in the /WORKSPACE file in the root of this repo.

The e2e folder contains more complex and isolated examples demonstrating flow such as a NodeJS GraphQL server.

Design

GraphQL by design supports many runtimes (JavaScript, Rust, Java, etc...). We decided that this ruleset would only support managing .graphql/.gql files and not contain rules which transpile GraphQL into other languages. Our reasoning was two-fold:

  1. We want to avoid rules_graphql from pulling in many more dependencies than required for clients. If we were to support every GraphQL runtime, the rules_graphql package would have deep requirements for every project.
  2. Many languages support multiple tools for transpiling GraphQL. We feel that individual projects should choose what's best for them, using rules_graphql as the base for their integration. We're not best qualified to select the universal GraphQL "best" stack for every language.

We hope that over time additional packages will be added such as rules_graphql_ts to support specific languages and would be happy to help anyone interested in contributing rules based on graphql_rules.

What we do

Given that we are strictly focusing on GraphQL management, rules_graphql primarily covers two useful responsibilities.

  1. graphql_library ~ validates syntax and symbol resolution for any number of GraphQL files.
  2. graphql_bundle ~ bundles GraphQL files or graphql_library targets into a single merged GraphQL file. Supports features such as tree-shaking to ensure graphs only contain reachable types.

Critically, both graphql_library and graphql_bundle contain their GraphQL files and required transitive GraphQL dependencies in their runfiles so that they can be included as data dependencies for most bazel rules—making it easy to load GraphQL files into your application with all of their dependencies.