Search in sources :

Example 1 with GraphQLTypeResolvingVisitor

use of graphql.schema.GraphQLTypeResolvingVisitor in project graphql-java by graphql-java.

the class SchemaUtil method replaceTypeReferences.

public static void replaceTypeReferences(GraphQLSchema schema) {
    final Map<String, GraphQLNamedType> typeMap = schema.getTypeMap();
    List<GraphQLSchemaElement> roots = new ArrayList<>(typeMap.values());
    roots.addAll(schema.getDirectives());
    SchemaTraverser schemaTraverser = new SchemaTraverser(schemaElement -> schemaElement.getChildrenWithTypeReferences().getChildrenAsList());
    schemaTraverser.depthFirst(new GraphQLTypeResolvingVisitor(typeMap), roots);
}
Also used : GraphQLTypeResolvingVisitor(graphql.schema.GraphQLTypeResolvingVisitor) GraphQLSchemaElement(graphql.schema.GraphQLSchemaElement) ArrayList(java.util.ArrayList) GraphQLNamedType(graphql.schema.GraphQLNamedType) SchemaTraverser(graphql.schema.SchemaTraverser)

Aggregations

GraphQLNamedType (graphql.schema.GraphQLNamedType)1 GraphQLSchemaElement (graphql.schema.GraphQLSchemaElement)1 GraphQLTypeResolvingVisitor (graphql.schema.GraphQLTypeResolvingVisitor)1 SchemaTraverser (graphql.schema.SchemaTraverser)1 ArrayList (java.util.ArrayList)1