graphql-java-spring-boot-example: Unable to access GraphQL server and GraphiQL

@PatriciaSauer has reported she is not able to access http://localhost:8080/graphql/schema.json and http://localhost:8080/graphiql (404 not found status).

The application doesn’t throw any errors at startup.

When a POST request is sent using Postman, a response like the following is sent:

{
  "timestamp": 1542268461797,
  "status": 405,
  "error": "Method Not Allowed",
  "exception": "org.springframework.web.HttpRequestMethodNotSupportedException",
  "message": "Request method 'POST' not supported",
  "path": "/graphql"
}

Does anyone have the same error or have any idea what might be happening? I cannot reproduce it. Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 17 (7 by maintainers)

Most upvoted comments

Great, thanks a lot @themanojshukla 👍

Hi @themanojshukla ,

thanks for your reply. Yes, I am now able to access http://localhost:8080/graphiql and http://localhost:8080/graphql 😃

Regards, Patricia

Hi @eh3rrera , @PatriciaSauer , sorry for so delayed response, I wasn’t having time to look into it since my last comment.

But, I found the solution, you can see https://github.com/themanojshukla/graphql this repository, it’s your forked repository on my account. I’ve modified two files,

one in pom.xml, added below dependency, so that GraphiQL tool can be used to understand better. // optional change

<dependency> <groupId>com.graphql-java</groupId> <artifactId>graphiql-spring-boot-starter</artifactId> <version>4.3.0</version> </dependency>

and second one is in GraphqlApplication.java // Only this change alone would fix your issue.

Added a ServletRegistrationBean to map /graphql path. Now, you can access it via http://localhost:8080/graphiql (from Graphiql Interface) or via postman on http://localhost:8080/graphql

Hope this solves your problem.

And, @eh3rrera I think now you can close this issue.

Thanks.