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

How to set headers after the client has been initialised ? #162

Closed
francelwebdev opened this issue Jun 13, 2022 · 1 comment
Closed

How to set headers after the client has been initialised ? #162

francelwebdev opened this issue Jun 13, 2022 · 1 comment

Comments

@francelwebdev
Copy link

Hello, how to set headers after the client has been initialised ?

@logaretm
Copy link
Owner

You can do this via plugins like this Auth header example here.

Or you can also use context object while creating the query or mutation:

const { execute } = useMutation(`mutation { test }`, {
  context: {
    headers: {
      'someheader': 'value'
    }
  }
});

const { execute } = useQuery({
  query: '{ test }',
  context: {
    headers: {
      someheader: 'value',
    },
  },
});

The latter approach isn't documented, I will make sure to add it.

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

2 participants