DEV Community


Discussion on: Ruby on Rails GraphQL API Tutorial: From 'rails new' to First Query

qz135636665908 profile image

Hi Isa, thanks for your reply, and sorry for the late reply, since I do not get any notifications. And yes the problem is exactly like what you said it appears as I trying to access localhost:3000/graphql. and it seems like it is getting a GET request. However in the route.rb I have wrote post "/graphql", to: "graphql#execute". Do you know if there are any other places that I might have made a mistake? Much appreciate!

Thread Thread
isalevine profile image
Isa Levine Author

Hi Jose-Xu, no problem at all on the late reply! :)

It might help to break down the expected behavior. When you say you are trying to access localhost:3000/graphql, do you mean:

  • you are trying to visit there in a browser and see something, or
  • you are trying to send a POST request with a GraphQL Query for a body?

The only way to access the endpoint at localhost:3000/graphql is by sending a POST request (in this tutorial's case, through Insomnia) and have the requests body be formatted as a GraphQL Query. So, trying to access localhost:3000/graphql from a browser will always return an error because it's never expecting a GET request.

On the other hand, if your issue is that you're getting errors with sending a POST request with a GraphQL Query body, then the issue is probably with the request body itself! Are you using Insomnia (or something similar, like Postman) to send the POST request? And if so, can you send a screenshot so we can look over it? :)

Thread Thread
Sloan, the sloth mascot
Comment deleted