-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discuss] Force GraphQL introspection queries to use different Content-Type #1510
Comments
I agree that, ideally, this is true. However, I've seen GraphQL servers that accept JSON but still require the Content-Type
Does this not cause an issue for sending regular queries as well, since Insomnia only supports sending GraphQL requests in JSON format? (ie. raw GraphQL query bodies are not supported) |
Ah. Didn't know that. In fact, I thought choosing GraphQL as "structured" type (vs "JSON" as "Text") would send the "application/graphql" Content-Type, which I noticed is not the case, after a round of testing (e.g. when creating a new request POST, or when changing the body type). Also the reference for supporting the application/graphql is here: https://graphql.org/learn/serving-over-http/#post-request
I know it's optional, but as soon as some backend libraries support it (as said in the text, express-graphql; but also GraphQL (Java) Servlet - although it's not clear in the README but I opened an issue for that: graphql-java-kickstart/graphql-java-servlet#186 - and probably some others...) I think why not supporting it. However I also learned that in this case, variables should be sent in the URL (https://rs.http3.lol/index.php?q=aHR0cHM6Ly9naXRodWIuY29tL0tvbmcvaW5zb21uaWEvaXNzdWVzL3NlZSBsYXN0IGFuc3dlcg): https://stackoverflow.com/questions/43675933/in-graphql-can-i-send-variables-with-content-type-application-graphql |
Just been informed the GraphQL Java Servlet's README has been fixed: graphql-java-kickstart/graphql-java-servlet#186 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
hu ho? I still needs this... |
Details
When requesting the schema from the GraphQL server, Insomnia uses the user-input HTTP header "Content-Type" to POST the IntrospectionQuery, whatever its value is.
However this value should always be
application/json
as that's how the IntrospectionQuery is formatted.In the case below (using the open API at https://countries.trevorblades.com/ ) I purposely entered a fictitious Content-Type to reflect how the value is picked-up by Insomnia. And the server fails with a 500 error.
To be noted: when I send GraphQL queries to my local/dev server, I usually use
Content-Type: application/graphql
but Insomnia fails to retrieve a schema too because the library handling the request (GraphQL Java) doesn't expect JSON in place of a pure GraphQL query.The text was updated successfully, but these errors were encountered: