MCPcopy Create free account
hub / github.com/Permify/permify / SchemaToGraph

Method SchemaToGraph

pkg/development/graph/schema.go:23–40  ·  view source on GitHub ↗

SchemaToGraph converts a schema definition into a graph representation.

()

Source from the content-addressed store, hash-verified

21
22// SchemaToGraph converts a schema definition into a graph representation.
23func (b Builder) SchemaToGraph() (g Graph, err error) {
24 for _, entity := range b.schema.GetEntityDefinitions() {
25 eg, err := b.EntityToGraph(entity)
26 if err != nil {
27 return Graph{}, fmt.Errorf("failed to convert entity to graph: %w", err)
28 }
29 g.AddNodes(eg.Nodes())
30 g.AddEdges(eg.Edges())
31 }
32 for _, rule := range b.schema.GetRuleDefinitions() {
33 rg, err := b.RuleToGraph(rule)
34 if err != nil {
35 return Graph{}, fmt.Errorf("failed to convert entity to graph: %w", err)
36 }
37 g.AddNodes(rg.Nodes())
38 }
39 return g, err
40}
41
42// EntityToGraph takes an entity definition and converts it into a graph
43// representation, returning the created graph and an error if any occurs.

Callers 1

visualizeFunction · 0.80

Calls 8

EntityToGraphMethod · 0.95
RuleToGraphMethod · 0.95
GetEntityDefinitionsMethod · 0.80
AddNodesMethod · 0.80
NodesMethod · 0.80
AddEdgesMethod · 0.80
EdgesMethod · 0.80
GetRuleDefinitionsMethod · 0.80

Tested by

no test coverage detected