feat(GraphQL): support application/graphql-response+json requests#2513
Draft
phryneas wants to merge 1 commit intomswjs:mainfrom
Draft
feat(GraphQL): support application/graphql-response+json requests#2513phryneas wants to merge 1 commit intomswjs:mainfrom
application/graphql-response+json requests#2513phryneas wants to merge 1 commit intomswjs:mainfrom
Conversation
phryneas
commented
May 28, 2025
| 'application/json', | ||
| ] | ||
|
|
||
| const wrappedResolver: typeof resolver = (info) => { |
Contributor
Author
There was a problem hiding this comment.
I'm sure there's a more elegant way to do this that I'm just not aware of....
Member
|
Hi, @phryneas. Thanks for opening this! It would help a lot if we started from the intended usage experience. How do you see people using MSW to mock queries done via the GraphQL-over-HTTP spec? Let's design the ideal usage and then work down from there to see what implementation that would require. From my limited understanding, all that should happen is that mocked responses from |
application/graphql-response+json requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This would add support for the GraphQL over HTTP spec: https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md#accept
The spec introduces a new mime type that future severs should be able to handle -
'application/graphql-response+json'instead of the traditional'application/json'.So right now, all tests using
HttpResponse.jsonwould need to switch over to a new constructing function.My suggestion here would be to just have
GraphQLHandlerreturn based on a list ofsupportedMimeTypesand the priority specified by the GraphQL client.Clients requesting
'application/json'would be served'application/json'while clients requesting"application/graphql-response+json, application/json;q=0.9"would be served'application/graphql-response+json'.Note that it would be possible to still always return
'application/json'and simulate a server that only speaks the old protocol by specifying asupportedMimeTypesof['application/json'].This is still lacking tests, but there is a good chance you want completely different behaviour so I'm opening this as-is for discussion.