Reputation: 1
I registered the bean, when trying to hit graphql endpoint from postman the request is not reaching to DGSFetcher class to perform action
Below is the code i wrote for registering new graphql endpoint "/graphql2"
@Bean
public ServletRegistrationBean<AbstractGraphQLHttpServlet> GraphQLServlet() throws IOException {
Path path = Paths.get("schema/schema.graphql");
String sdl = new String(Files.readAllBytes(path));
TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(sdl);
RuntimeWiring wiring = buildRuntimeWiring(typeRegistry);
GraphQLSchema schema = new SchemaGenerator().makeExecutableSchema(typeRegistry, wiring);
GraphQLHttpServlet graphQLHttpServlet = GraphQLHttpServlet.with(schema);
ServletRegistrationBean<AbstractGraphQLHttpServlet> registration = new ServletRegistrationBean<>(
graphQLHttpServlet, "/graphql2");
registration.setName("Another GraphQL Endpoint");
return registration;
}
private RuntimeWiring buildRuntimeWiring(TypeDefinitionRegistry registry) {
return EchoingWiringFactory.newEchoingWiring(wiring -> {
Map<String, ScalarTypeDefinition> scalars = registry.scalars();
scalars.forEach((name, v) -> {
if (!ScalarInfo.isGraphqlSpecifiedScalar(name)) {
wiring.scalar(fakeScalar(name));
}
});
});
}
Upvotes: 0
Views: 58