0.19.1
0.18.1
0.28.1
Yes.
Darwin and linux, both amd64.
Executed this rule:
load("@io_bazel_rules_go//go:def.bzl", "go_path")
go_path(
name = "gqlgen_path",
mode = "copy",
deps = ["@com_github_99designs_gqlgen//:gqlgen"],
visibility = ["//visibility:public"],
)
for
go_repository(
name = "com_github_99designs_gqlgen",
importpath = "github.com/99designs/gqlgen",
version = "v0.9.3",
sum = "h1:BWOMuDFhpuvzbuUFgCL1OSfAM2lvnYgpoCXetDvbnHY=",
patches = ["//:com_github_99designs_gqlgen.patch"],
)
Which applies a patch to list *.gotpl files inside the data attribute of the generated BUILD files:
diff -urN plugin/modelgen/BUILD.bazel plugin/modelgen/BUILD.bazel
--- plugin/modelgen/BUILD.bazel 2019-08-20 16:36:43.000000000 -0300
+++ plugin/modelgen/BUILD.bazel 2019-08-20 16:40:38.000000000 -0300
@@ -1,6 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
+ data = ["models.gotpl"],
name = "go_default_library",
srcs = ["models.go"],
importpath = "github.com/99designs/gqlgen/plugin/modelgen",
Full WORKSPACE and patch files are pasted at the end of the issue.
The files specified in the data attributes should appear in their respective directories.
The data files appear together in multiple directories:
cd bazel-genfiles/gqlgen_path/src/github.com/99designs
find -L . -name "object.gotpl" | wc -l
9
This seems related to package dependencies. For example, bazel-genfiles/gqlgen_path/src/github.com/99designs/gqlgen/plugin/modelgen/ contains links to files that are not supposed to be in that directory, but belong to com_github_99designs_gqlgen/codegen.
The go_library rule for com_github_99designs_gqlgen/plugin/modelgen/ is:
go_library(
data = ["models.gotpl"],
name = "go_default_library",
srcs = ["models.go"],
importpath = "github.com/99designs/gqlgen/plugin/modelgen",
visibility = ["//visibility:public"],
deps = [
"//codegen/config:go_default_library",
"//codegen/templates:go_default_library",
"//internal/code:go_default_library",
"//plugin:go_default_library",
"@com_github_vektah_gqlparser//ast:go_default_library",
],
)
It depends on //codegen/config and //codegen/config. However, those libraries do not (explicitly?) depend on their parent, //codegen. Nevertheless, data files for //codegen are linked in the github.com/99designs/gqlgen/plugin/modelgen directory.
This is unexpected. What is also unexpected is that data files have this behavior, because even though the library depends on *.go files as well, those are not linked in the library's directory.
WORKESPACE file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
rules_go_version = "0.19.1"
http_archive(
name = "io_bazel_rules_go",
sha256 = "8df59f11fb697743cbb3f26cfb8750395f30471e9eabde0d174c3aebc7a1cd39",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/{}/rules_go-{}.tar.gz".format(rules_go_version, rules_go_version),
"https://github.com/bazelbuild/rules_go/releases/download/{}/rules_go-{}.tar.gz".format(rules_go_version, rules_go_version),
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains()
gazelle_version = "0.18.1"
http_archive(
name = "bazel_gazelle",
sha256 = "be9296bfd64882e3c08e3283c58fcb461fa6dd3c171764fcc4cf322f60615a9b",
urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/{}/bazel-gazelle-{}.tar.gz".format(gazelle_version, gazelle_version),
"https://github.com/bazelbuild/bazel-gazelle/releases/download/{}/bazel-gazelle-{}.tar.gz".format(gazelle_version, gazelle_version),
],
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
gazelle_dependencies()
go_repository(
name = "com_github_99designs_gqlgen",
importpath = "github.com/99designs/gqlgen",
version = "v0.9.3",
sum = "h1:BWOMuDFhpuvzbuUFgCL1OSfAM2lvnYgpoCXetDvbnHY=",
patches = ["//:com_github_99designs_gqlgen.patch"],
)
go_repository(
name = "com_github_pkg_errors",
importpath = "github.com/pkg/errors",
sum = "h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=",
version = "v0.8.1",
)
go_repository(
name = "com_github_urfave_cli",
importpath = "github.com/urfave/cli",
sum = "h1:wYSSj06510qPIzGSua9ZqsncMmWE3Zr55KBERygyrxE=",
version = "v1.21.0",
)
# Dependencies below
go_repository(
name = "in_gopkg_yaml_v2",
importpath = "gopkg.in/yaml.v2",
sum = "h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=",
version = "v2.2.2",
)
go_repository(
name = "com_github_vektah_gqlparser",
importpath = "github.com/vektah/gqlparser",
sum = "h1:ZsyLGn7/7jDNI+y4SEhI4yAxRChlv15pUHMjijT+e68=",
version = "v1.1.2",
)
go_repository(
name = "com_github_gorilla_websocket",
importpath = "github.com/gorilla/websocket",
sum = "h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ=",
version = "v1.2.0",
)
go_repository(
name = "com_github_agnivade_levenshtein",
importpath = "github.com/agnivade/levenshtein",
sum = "h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ=",
version = "v1.0.1",
)
go_repository(
name = "com_github_hashicorp_golang_lru",
importpath = "github.com/hashicorp/golang-lru",
sum = "h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=",
version = "v0.5.0",
)
Path file:
diff -urN codegen/BUILD.bazel codegen/BUILD.bazel
--- codegen/BUILD.bazel 2019-08-20 16:36:43.000000000 -0300
+++ codegen/BUILD.bazel 2019-08-20 16:40:02.000000000 -0300
@@ -1,6 +1,16 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
+ data = [
+ "directives.gotpl",
+ "args.gotpl",
+ "field.gotpl",
+ "type.gotpl",
+ "generated!.gotpl",
+ "interface.gotpl",
+ "input.gotpl",
+ "object.gotpl"
+ ],
name = "go_default_library",
srcs = [
"args.go",
diff -urN plugin/modelgen/BUILD.bazel plugin/modelgen/BUILD.bazel
--- plugin/modelgen/BUILD.bazel 2019-08-20 16:36:43.000000000 -0300
+++ plugin/modelgen/BUILD.bazel 2019-08-20 16:40:38.000000000 -0300
@@ -1,6 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
+ data = ["models.gotpl"],
name = "go_default_library",
srcs = ["models.go"],
importpath = "github.com/99designs/gqlgen/plugin/modelgen",
diff -urN plugin/resolvergen/BUILD.bazel plugin/resolvergen/BUILD.bazel
--- plugin/resolvergen/BUILD.bazel 2019-08-20 16:36:43.000000000 -0300
+++ plugin/resolvergen/BUILD.bazel 2019-08-20 16:41:20.000000000 -0300
@@ -1,6 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
+ data = ["resolver.gotpl"],
name = "go_default_library",
srcs = ["resolver.go"],
importpath = "github.com/99designs/gqlgen/plugin/resolvergen",
diff -urN plugin/stubgen/BUILD.bazel plugin/stubgen/BUILD.bazel
--- plugin/stubgen/BUILD.bazel 2019-08-20 16:36:43.000000000 -0300
+++ plugin/stubgen/BUILD.bazel 2019-08-20 16:42:09.000000000 -0300
@@ -1,6 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
+ data = ["stubs.gotpl"],
name = "go_default_library",
srcs = ["stubs.go"],
importpath = "github.com/99designs/gqlgen/plugin/stubgen",
We seem to be including all runfiles for each package, including those from transitive dependencies. We should only include direct runfiles.
I was looking for bazel rules to execute gqlgen as well. Is there currently any discussion on if and when to tackle this?
Most helpful comment
I was looking for bazel rules to execute
gqlgenas well. Is there currently any discussion on if and when to tackle this?