Skip to content

Commit

Permalink
add more documentation for viz subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
benweint committed Jun 2, 2024
1 parent 329606f commit e1d83b4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/commands/viz.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ type VizCmd struct {
InterfacesAsUnions bool `name:"interfaces-as-unions" help:"Treat interfaces as unions rather than objects for the purposes of graph construction."`
}

func (c *VizCmd) Help() string {
return `To render the resulting graph to a PDF, you can use the 'dot' tool that comes with GraphViz:
gquil viz schema.graphql | dot -Tpdf >out.pdf
For GraphQL schemas with a large number of types and fields, the resulting diagram may be very large. You can trim it down to a particular region of interest using the --from and --depth flags to indicate a starting point and maximum traversal depth to use when traversing the graph.
gquil viz --from Reviews --depth 2 schema.graphql | dot -Tpdf >out.pdf
GraphQL unions are represented as nodes in the graph with outbound edges to each member type. Interfaces are represented in the same way as object types by default, with one outbound edge per field, pointing to the type of that field. To instead render interfaces with one outbound edge per implementing type, you can use the --interfaces-as-unions flag.`
}

func (c *VizCmd) Run(ctx Context) error {
s, err := loadSchemaModel(c.SchemaFiles)
if err != nil {
Expand Down

0 comments on commit e1d83b4

Please sign in to comment.