"""Contains macros for working with github.com/99designs/gqlgen in Bazel""" GO = "@go_sdk//:bin/go" GQLGEN = "@com_github_99designs_gqlgen//:gqlgen" # Common pieces for both generation macros ARGS = [ "$(location %s)" % GO, "$(location %s)" % GQLGEN, ] DATA = [ GO, GQLGEN, ] def gqlgen(name, pkg = ""): """Run 99designs/gqlgen recursively for the given package. Args: name: The name of the produced rule, and the name this rule will be callable from. e.g., name = "gen_talaria_rbac" in controllers/talaria/BUILD.bazel is callable as //controllers/talaria:gen_talaria_rbac. pkg: Relative path from repo root to Go package to generate GQL code from. Don't provide if this is being defined in the desired package. """ native.sh_binary( name = name, srcs = ["//hack/tools/gqlgen:gqlgen.sh"], args = ARGS + [ pkg if pkg != "" else native.package_name(), ], data = DATA, )