I wanted to see all of my dependency graph for a bazel target, for that I can use below query
bazelisk query --notool_deps --noimplicit_deps "deps(//sample-target:sample-target)" --output graph
this will show me the dependency graph,
now I wanted to show more data on each node, for example if a node/target has attribute tags I wanted to show all tags there
is this possible?
Filtering by tag can be done with the
attr()function:https://bazel.build/query/language#attr
But I don't think there's a direct way to print all the tags. A way around this is to use another output format like
--output=streamed_jsonprotowhich will include the attributes of the targets among other things.For example:
bazel query --notool_deps --noimplicit_deps "gen" --output=streamed_jsonprotowill include:Or if you feel like getting into it, the code to generate the graph output is here and it might not be too difficult to have it add the tags to the node text:
https://github.com/bazelbuild/bazel/blob/3713606de9aa5d85f71cc07d466b911d79024183/src/main/java/com/google/devtools/build/lib/query2/query/output/GraphOutputWriter.java#L167