Skip to content
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

feat!: add spec compliant default Accept header #618

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

jonkoops
Copy link
Collaborator

@jonkoops jonkoops commented Nov 6, 2023

Adds the Accept header to all requests with a spec-compliant mime-type. This PR also does some code cleanup and removes support for the legacy application/graphql+json mime type.

Closes #140

@@ -62,65 +61,6 @@ test(`minimal raw query with response headers`, async () => {
expect(headers.get(`X-Custom-Header`)).toEqual(reqHeaders![`X-Custom-Header`])
})

test(`minimal raw query with response headers and new graphql content type`, async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is no longer relevant as this mime-type is no longer spec compliant.

expect(result).toEqual({ ...body, status: 200 })
})

test(`minimal raw query with response headers and application/graphql-response+json response type`, async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need this test as this header is now sent by default. Also this wrongly set the Content-Type header, whereas the content-type should always be application/json.

expect(result).toEqual({ ...body, status: 200 })
})

test(`content-type with charset`, async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was not doing anything, the relevant code was already commented out.

@@ -336,31 +276,6 @@ test.skip(`extra fetch options`, async () => {
`)
})

test(`case-insensitive content-type header for custom fetch`, async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was testing internal behavior of Headers, so this should no longer be needed.

@@ -107,24 +107,6 @@ describe(`using class`, () => {
expect(mock.requests[0]?.headers[`x-foo`]).toEqual(`new`)
})
})

describe(`allows content-type header to be overwritten`, () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was moved into the main suite.

Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jasonkuhrt jasonkuhrt merged commit 99a192e into graffle-js:main Nov 7, 2023
7 checks passed
@jonkoops jonkoops deleted the add-accept-header branch November 10, 2023 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graphql Error 200
2 participants