Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel: generate graphql operation interfaces, css module typings #45682

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions client/jetbrains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("@aspect_rules_js//js:defs.bzl", "js_library")

js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"webview/src/**/*.ts",
"webview/src/**/*.tsx",
],
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
[
"webview/src/graphql-operations.ts",
],
),
)

generate_graphql_operations(
name = "graphql_operations",
srcs = [
"//client/jetbrains/webview:graphql_operations_files",
],
interface_name = "JetBrainsGraphQlOperations",
output = "src/graphql-operations.ts",
)
19 changes: 19 additions & 0 deletions client/jetbrains/webview/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("//client/shared/dev:tools.bzl", "module_style_typings")
load("@aspect_rules_js//js:defs.bzl", "js_library")

module_style_typings(
name = "module_style_typings",
deps = ["//client/wildcard"],
)

js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
),
visibility = ["//client/jetbrains:__pkg__"],
)
6 changes: 6 additions & 0 deletions client/search-ui/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("//client/shared/dev:tools.bzl", "module_style_typings")

module_style_typings(
name = "module_style_typings",
deps = ["//client/wildcard"],
)
27 changes: 27 additions & 0 deletions client/search/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("@aspect_rules_js//js:defs.bzl", "js_library")

js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
[
"src/graphql-operations.ts",
],
),
)

generate_graphql_operations(
name = "graphql_operations",
srcs = [
":graphql_operations_files",
],
interface_name = "SearchGraphQlOperations",
output = "src/graphql-operations.ts",
)
36 changes: 35 additions & 1 deletion client/shared/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
load("@aspect_rules_js//js:defs.bzl", "js_library", "js_run_binary")
load("//client/shared/dev:generate_schema.bzl", "generate_schema")
load("//client/shared/dev:generate_graphql_operations.bzl", "generate_graphql_operations")
load("//client/shared/dev:tools.bzl", "module_style_typings")

module_style_typings(
name = "module_style_typings",
)

generate_graphql_operations(
name = "graphql_operations",
srcs = [
":graphql_operations_files",
],
interface_name = "SharedGraphQlOperations",
output = "src/graphql-operations.ts",
)

js_library(
name = "graphql_operations_files",
# Keep in sync with glob in client/shared/dev/generateGraphQlOperations.js
srcs = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
[
"src/testing/**/*.*",
"src/schema.ts",
# TODO: Ignore legacy build generated file as it conflicts with the Bazel
# build. This can be removed after the migration.
"src/graphql-operations.ts",
],
),
visibility = ["//client/shared:__pkg__"],
)

js_run_binary(
name = "graphql_schema",
Expand Down
37 changes: 31 additions & 6 deletions client/shared/dev/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library")

js_binary(
name = "generate_schema",
data = [
"//:node_modules/json-schema-to-typescript",
"//:node_modules/mz",
],
entry_point = "generateSchema.js",
visibility = ["//client/shared:__pkg__"],
)

js_binary(
name = "generate_graphql_schema",
Expand All @@ -16,12 +26,27 @@ js_binary(
visibility = ["//client/shared:__pkg__"],
)

js_library(
name = "extract_graphql_operation_codegen_plugin",
srcs = [
"extractGraphQlOperationCodegenPlugin.js",
],
deps = [
"//:node_modules/graphql",
"//:node_modules/gulplog",
],
)

js_binary(
name = "generate_schema",
name = "generate_graphql_operations",
data = [
"//:node_modules/json-schema-to-typescript",
"//:node_modules/mz",
":extract_graphql_operation_codegen_plugin",
"//:node_modules/@graphql-codegen/cli",
"//:node_modules/@graphql-codegen/typescript",
"//:node_modules/@graphql-codegen/typescript-operations",
"//:node_modules/prettier",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to automate maintenance of the list of dependencies here somehow later?

"//cmd/frontend/graphqlbackend:graphql_schema",
],
entry_point = "generateSchema.js",
visibility = ["//client/shared:__pkg__"],
entry_point = "generateGraphQlOperations.js",
visibility = ["//client:__subpackages__"],
)