Send spec-compliant Accept header in fetchers#4199
Send spec-compliant Accept header in fetchers#4199trevor-scheer wants to merge 3 commits intomainfrom
Conversation
Add `application/graphql-response+json` as the preferred content type per the GraphQL over HTTP spec, with `application/json` as a fallback. Applied to both createSimpleFetcher and createMultipartFetcher.
🦋 Changeset detectedLatest commit: bceaa66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest changes of this PR are not available as canary, since there are no linked |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4199 +/- ##
=======================================
Coverage 63.96% 63.96%
=======================================
Files 35 35
Lines 3086 3086
Branches 934 934
=======================================
Hits 1974 1974
Misses 1107 1107
Partials 5 5 🚀 New features to boost your workflow:
|
|
The currently specified — persists an error. Leaving off the quality rating causes a media type to be treates as if I'm fairly well certain that one of For sake of understanding, I offer two options. The first prefers Note — both of my offered options presume that |
|
|
||
| const SPEC_ACCEPT = 'application/graphql-response+json, application/json;q=0.9'; | ||
| const MULTIPART_ACCEPT = `${SPEC_ACCEPT}, multipart/mixed`; | ||
|
|
There was a problem hiding this comment.
| const QUERY = '{ __typename }'; | |
| const BASE_URL = 'http://localhost'; |
I don't want to be annoying, but these vars are repeated 5 times each 😄
Summary
application/graphql-response+jsonas the preferred content type per the GraphQL over HTTP spec, falling back toapplication/json;q=0.9createSimpleFetcher(which previously sent noAcceptheader) andcreateMultipartFetcher(which sentapplication/json, multipart/mixed)Closes #4189
Changes
createSimpleFetcher: addedaccept: 'application/graphql-response+json, application/json;q=0.9'createMultipartFetcher: changed accept fromapplication/json, multipart/mixedtoapplication/graphql-response+json, application/json;q=0.9, multipart/mixedoptions.headers,fetcherOpts.headers) to override the defaultacceptHeaders.spec.tswith tests covering default headers and override behaviorValidation Steps
yarn dev:graphiqlto start the dev server{ __typename })Acceptrequest header should beapplication/graphql-response+json, application/json;q=0.9, multipart/mixed