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

Default headers in @graphql-tools/url-loader are case sensitive #4482

Open
4 tasks
Tracked by #5201 ...
vuode opened this issue May 24, 2022 · 0 comments
Open
4 tasks
Tracked by #5201 ...

Default headers in @graphql-tools/url-loader are case sensitive #4482

vuode opened this issue May 24, 2022 · 0 comments

Comments

@vuode
Copy link

vuode commented May 24, 2022

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

Default headers (accept and content-type) for UrlLoader are set with the keys in lower case. If you try to override them but use capitalized keys, the headers get duplicated. For example, if I set the header the way it is demonstrated in the documentation, I send both accept and Accept headers. The same problem occurs with content-type header.

For me this produced a bag with introspection of this endpoint—https://api.spacex.land/graphql

To Reproduce
Steps to reproduce the behavior:

  1. Create a mock customFetch function to capture headers to be send
  2. Override default headers with non-lowercase keys to the loader's load method
  3. Provide the mock function to the loader's load method
  4. Log the headers

Sandbox with reproduced error

How the error was found:

  1. Provide the loader's load function with url https://api.spacex.land/graphql and set the Set-Content header to default value of application/json
  2. Catch the error
  3. Comment previously set header or make it lowercase and you won't receive the error

Sandbox with reproduction

Expected behavior

  1. If the headers with internally set default values are overridden, incoming headers are made lowercase before being applied.
  2. There is some information provided in the documentation about those 2 headers being set by default, so people won't unnecessarily override them with the same values.

Environment:

  • OS: MacOS 12.3.1
  • @graphql-tools/url-loader:
  • NodeJS: 17.3.0

Additional context

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

No branches or pull requests

1 participant