1

I have a GraphQL schema:

enum CustomType { Foo Bar } 

But I need to add enum items from my database. For that, I have made a Visitor that modify the schema model during runtime:

@Configuration(proxyBeanMethods = false) class GraphQlConfig { @Bean public GraphQlSourceBuilderCustomizer sourceBuilderCustomizer() { return builder -> builder.typeVisitors(List.of(new AssetGraphQlVisitor())); } } 
public class AssetGraphQlVisitor extends GraphQLTypeVisitorStub { @Override public TraversalControl visitGraphQLEnumType(GraphQLEnumType node, TraverserContext<GraphQLSchemaElement> context) { GraphQLEnumType returnedNode = node; if (node.getName().equals("CustomType")) { returnedNode = returnedNode .transform(builder -> CustomType.getAll().forEach(type -> builder.value(type.getName()))); } return super.visitGraphQLEnumType(returnedNode, context); } } 

This seems to work well but when I go to my GraphiQL web interface, my custom types aren't present in the displayed schema...

How can I update the schema used by GraphiQL received from Spring GraphQL ?

Thanks!

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.