Bad GET request: path was not "/schema.json" or no query variable named "query" given
I'm getting:
Bad GET request: path was not "/schema.json" or no query variable named "query" given
while using:
curl -k -H "Content-Type: application/json" -H "Authorization: Bearer <token here>" -X POST -d '{ "operationName": null, "query": "subscription values($sensorId: String) {\n values(sensorId: $sensorId) {\n sensor\n value\n timestamp\n __typename\n }\n}\n", "variables": {"sensorId": 33} }' http://localhost:9999/graphql
What's happening? How can one solve this?
EDIT: I don't know if this can help but this happens also in Mutations and Queries since I use
DataFetcher<Flowable<TYPE>>
Can you use triple ticks next time for better readability? :)
Looks like you're sending a subscription to the /graphql endpoint. Take a look at the subsription example and start from there.
Hi @oliemansm , thanks for your response. Is there any issue sending subscriptions to the /graphql endpoint? I have successfully tested locally and it works well with HTTP chunked responses.
You say you use DataFetcher. How are you using this? The information is rather limited to be able to say anything sensible here. Why do you think this is even an issue with graphql-java-tools? There are multiple working examples in the graphql-spring-boot project. I'd start with one of those working examples if I were you and move towards the solution you have in mind.
I had the same problem due to a cast exception in my error handling, the error simply being that fetching the schema broke our max query depth complexity. I suggest adding a custom log level of debug for graphql.kickstart to see what's actually causing this
Closed for inactivity.
I don't know how nobody resolved this issue yet. I see a lot of people using Graphql and having the same problem e.g. " Bad GET request: path was not "/schema.json" or no query variable named "query" given " In Graphql, the biggest problem is logging. I don't know the purpose of the log if you are not able to provide a proper error message? e.g. I was getting this error, and I dive deep into debugging (class HttpRequestHandlerImpl) and I found out that the problem was the field that was removed. So, why would it be so hard to print the log which is already provided in such a deep debugging state?
any one plz tell me clear Solution?
any one plz tell me clear Solution?
Make sure your schema file and Dto object have the same variables, with the same naming. If the problem persists, usually, project rebuild helps. Especially if you are using Lombok and Mapstruct. In 99% of the cases, Lombok makes a problem. If there is still a problem, then, I suggest debugging. Line by line. Ironically, GraphQL, in-depth has a proper error, with a very good description, but, then, they are converting that error into mentioned stupid error. I don't know why they are doing that, but they do.
For example, I had the same error, and I did a debug, line by line, and in-deep, I saw that the actual error is, Field xxx not defined in the schema, or Method xxx not found, or something like that.. As you see, an error is a proper one. But it's converted to a stupid general error message.
hey, how do we debug graphql line by line? any tutorial to setup that debugging???
any tutorial to setup that debugging
You have to debug your own code. When an exception is thrown, open that line and resend the request until you find the point when an exception occurs. This is very hard to do, especially, because it's not needed at all. I still don't understand why somebody would hide a perfectly valid message that explains the problem with a general message that tells you nothing...
Hi, It is not about dtos or something else. Graphql simply returns empty response in any case. I fixed this problem by Downgrading the federation-graphql-java-support dependency to 0.5.0 worked fine for me.
<dependency>
<groupId>com.apollographql.federation</groupId>
<artifactId>federation-graphql-java-support</artifactId>
<version>0.5.0</version>
</dependency>
Note: You need to add jcenter repository to your pom.xml
<repository>
<id>jcenter</id>
<name>jcenter</name>
<url>https://jcenter.bintray.com</url>
</repository>