Skip to content

Add custom headers on request #508

Open

Description

Your use case

We are looking for a way to add a custom defined header on the useAsyncQuery function of the client. In our case the visitors Customer Id needs to be added to some requests. But it seems we are not able to override the headers from the query location.

      const query = gql`
        query getShips($limit: Int!) {
          ships(limit: $limit) {
            id
            name
          }
        }
      `
      const variables = { limit: 5 }
      const { data } = await useAsyncQuery(query, variables)

The solution you'd like

I would be nice to add custom headers like below, they should than be merged with the auth headers specified when defining the client.

const query = gql`
  query getShips($limit: Int!) {
    ships(limit: $limit) {
      id
      name
    }
  }
`
const variables = { limit: 5 }
const headers = { customer-id: "123456789" }

const { data } = await useAsyncQuery(query, variables, headers)

Possible alternatives

No response

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions