@@ -29,6 +29,7 @@ func sanitizeComment(d Describer) string {
29
29
30
30
func NewVertex (node ast.Node ) Vertex {
31
31
var name string
32
+
32
33
switch node .GetKind () {
33
34
case kinds .ScalarDefinition :
34
35
obj := node .(* ast.ScalarDefinition )
@@ -125,7 +126,9 @@ func buildPrunedGraph(doc *ast.Document) graph.Graph[string, Vertex] {
125
126
// Build edges between vertices.
126
127
buildEdges (g )
127
128
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
129
132
return prune (g )
130
133
}
131
134
@@ -154,6 +157,9 @@ func loadTopLevelDefinitions(g graph.Graph[string, Vertex], doc *ast.Document) {
154
157
}
155
158
}
156
159
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
157
163
func prune (in graph.Graph [string , Vertex ]) graph.Graph [string , Vertex ] {
158
164
m , err := in .AdjacencyMap ()
159
165
if err != nil {
@@ -166,9 +172,13 @@ func prune(in graph.Graph[string, Vertex]) graph.Graph[string, Vertex] {
166
172
continue
167
173
}
168
174
175
+ // Retrieve the vertex (GraphQL type) by its name
169
176
def := must (in .Vertex (defName ))
170
177
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
172
182
_ = out .AddVertex (def )
173
183
174
184
// Add its dependent vertices
@@ -190,6 +200,7 @@ func must(v Vertex, err error) Vertex {
190
200
}
191
201
192
202
func isDesired (definitionName string ) bool {
203
+ // TODO deprecate in favor of config
193
204
for _ , d := range desiredDefinitions {
194
205
if definitionName == d {
195
206
return true
@@ -200,6 +211,7 @@ func isDesired(definitionName string) bool {
200
211
}
201
212
202
213
func isBasicType (t string ) bool {
214
+ // https://graphql.org/graphql-js/basic-types/
203
215
return t == "String" || t == "Float" || t == "Int" || t == "Boolean" || t == "ID"
204
216
}
205
217
0 commit comments