No schema.json generated
khteh opened this issue · 1 comments
Describe the bug
A clear and concise description of what the bug is.
I have the following ServletRegistrationBean
but navigating to http://localhost:8080/graphql-book/schem.json in GraphiQL show that it is not generated / found.
@Bean
//ServletRegistrationBean graphQLServletRegistrationBean(GraphQLSchema schema, ExecutionStrategy executionStrategy, List<GraphQLOperationListener> operationListeners)
ServletRegistrationBean servletRegistrationBean()
{
try {
GraphQLSchema schema = SchemaParser.newParser()
.resolvers(bookResolver(authorRepository_), mutation(bookRepository_, authorRepository_), query(bookRepository_, authorRepository_))
.file("graphql/author.graphqls")
.file("graphql/book.graphqls")
.file("graphql/empty.graphqls")
.build().makeExecutableSchema();
ExecutionStrategy executionStrategy = new AsyncExecutionStrategy();
//GraphQLHttpServlet servlet = new SimpleGraphQLHttpServlet(schema, executionStrategy);
final SimpleGraphQLHttpServlet servlet = SimpleGraphQLHttpServlet.newBuilder(schema)
// .withInstrumentation(factory.getInstrumentations())
.build();
Server svr = config_.getServer();
Servlet srvlet = svr.getServlet();
System.out.println(AppConfig.class.getName() + ".servletRegistrationBean() port: "+svr.getPort() + ", contextPath: " + srvlet.getContextPath());
ServletRegistrationBean bean = new ServletRegistrationBean(servlet, srvlet.getContextPath());
return bean;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Query class:
@AllArgsConstructor
public class Query implements GraphQLQueryResolver {
protected BookRepository bookRepository;
protected AuthorRepository authorRepository;
}
BookQuery subclassing Query:
public class BookQuery extends Query {//implements GraphQLQueryResolver {
private static final Log log = LogFactory.getLog(BookQuery.class);
@Builder
public BookQuery(AuthorRepository author, BookRepository book)
{
super(book, author);
}
public Iterable<Book> findAllBooks() {
log.info(BookQuery.class.getName() + ".findAllBooks()");
return bookRepository.findAll();
}
public long countBooks() { return bookRepository.count(); }
}
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS] WIndows 10
- Browser [e.g. chrome, safari] Chrome
- Version [e.g. 22]
Additional context
Add any other context about the problem here.
That sounds more like a GraphiQL question. GraphiQL is expecting the schema.json to exist on the default location, i.e. /graphql/schema.json
, while you are apparently mounting the servlet onto a custom url making the schema location /graphql-book/schema.json
. So if you're diverting from the defaults, you'll have to put in some additional effort too to tell GraphiQL where it can find the schema.json.
Just verified that the servlet itself is working fine with default configuration, and this seems very specific to the way you want to do things, which means you're better off at Stackoverflow.