urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.54k stars 444 forks source link

Passing a `Headers` object results in an error #3504

Closed konomae closed 4 months ago

konomae commented 4 months ago

Describe the bug

urql accepts HeadersInit (via RequestInit), it appears that a Headers object can be passed. But when I actually do, it causes errors.

const headers = new Headers();

const client = new Client({
  url: "https://localhost:3000/graphql",
  exchanges: [fetchExchange],
  fetchOptions: { headers },
});

const response = await client.query("{ ping }", {});
[Network] Headers.append: "append(name, value) { /* omit */ }" is an invalid header value.

I think: 🤔

Reproduction

https://github.com/konomae/urql-headers-repro

Urql version

urql 4.2.3 node 20.11

Validations