@@ -29,6 +29,7 @@ func sanitizeComment(d Describer) string {
2929
3030func NewVertex (node ast.Node ) Vertex {
3131 var name string
32+
3233 switch node .GetKind () {
3334 case kinds .ScalarDefinition :
3435 obj := node .(* ast.ScalarDefinition )
@@ -125,7 +126,9 @@ func buildPrunedGraph(doc *ast.Document) graph.Graph[string, Vertex] {
125126 // Build edges between vertices.
126127 buildEdges (g )
127128
128- // Prunes any vertices that don't appear in any edges
129+ // Prune our graph:
130+ // 1. We filter out any vertices (GQL types) that we don't explicitly want
131+ // 2. We filter out any fields within those GQL types
129132 return prune (g )
130133}
131134
@@ -154,6 +157,9 @@ func loadTopLevelDefinitions(g graph.Graph[string, Vertex], doc *ast.Document) {
154157 }
155158}
156159
160+ // Prune our graph:
161+ // 1. We filter out any vertices (GQL types) that we don't explicitly want
162+ // 2. We filter out any fields within those GQL types
157163func prune (in graph.Graph [string , Vertex ]) graph.Graph [string , Vertex ] {
158164 m , err := in .AdjacencyMap ()
159165 if err != nil {
@@ -166,9 +172,13 @@ func prune(in graph.Graph[string, Vertex]) graph.Graph[string, Vertex] {
166172 continue
167173 }
168174
175+ // Retrieve the vertex (GraphQL type) by its name
169176 def := must (in .Vertex (defName ))
170177
171- // Add vertex
178+ // TODO clone the type definition and filter out fields
179+ // def = filter(clone(def))
180+
181+ // Add vertex (GraphQL type) to our new, outgoing graph
172182 _ = out .AddVertex (def )
173183
174184 // Add its dependent vertices
@@ -190,6 +200,7 @@ func must(v Vertex, err error) Vertex {
190200}
191201
192202func isDesired (definitionName string ) bool {
203+ // TODO deprecate in favor of config
193204 for _ , d := range desiredDefinitions {
194205 if definitionName == d {
195206 return true
@@ -200,6 +211,7 @@ func isDesired(definitionName string) bool {
200211}
201212
202213func isBasicType (t string ) bool {
214+ // https://graphql.org/graphql-js/basic-types/
203215 return t == "String" || t == "Float" || t == "Int" || t == "Boolean" || t == "ID"
204216}
205217
0 commit comments