Skip to content

Commit 8d3f322

Browse files
committed
Add tests
1 parent 4685314 commit 8d3f322

2 files changed

Lines changed: 612 additions & 0 deletions

File tree

lib/src/main/java/graphql/nadel/engine/blueprint/NadelFastSchemaTraverser.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package graphql.nadel.engine.blueprint
22

3+
import graphql.introspection.Introspection
34
import graphql.schema.GraphQLSchema
5+
import graphql.schema.idl.DirectiveInfo
6+
import graphql.schema.idl.ScalarInfo
47

58
/**
69
* Significantly faster than normal [graphql.schema.SchemaTraverser] as it's simpler.
@@ -10,6 +13,29 @@ import graphql.schema.GraphQLSchema
1013
* That's 4x faster.
1114
*/
1215
internal class NadelSchemaTraverser {
16+
fun traverse(
17+
schema: GraphQLSchema,
18+
visitor: NadelSchemaTraverserVisitor,
19+
) {
20+
val typeRoots = schema.typeMap.asSequence()
21+
.map { (_, type) ->
22+
NadelSchemaTraverserElement.from(type)
23+
}
24+
.filterNot {
25+
val nodeName = it.node.name
26+
Introspection.isIntrospectionTypes(nodeName) || ScalarInfo.isGraphqlSpecifiedScalar(nodeName)
27+
}
28+
val directiveRoots = schema.directives.asSequence()
29+
.map { directive ->
30+
NadelSchemaTraverserElement.from(directive)
31+
}
32+
.filterNot {
33+
DirectiveInfo.isGraphqlSpecifiedDirective(it.node.name)
34+
}
35+
36+
return traverse((typeRoots + directiveRoots).asIterable(), visitor)
37+
}
38+
1339
fun traverse(
1440
schema: GraphQLSchema,
1541
roots: Iterable<String>,

0 commit comments

Comments
 (0)