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

custom headers #1084

Open
happy-machine opened this issue Oct 21, 2020 · 5 comments
Open

custom headers #1084

happy-machine opened this issue Oct 21, 2020 · 5 comments

Comments

@happy-machine
Copy link

Hi there,

I'm looking at examples for setting headers in defaultOptions but these will affect all my queries, how can i pass custom headers to queries (different headers to different queries?)

@dmitry
Copy link

dmitry commented Oct 28, 2020

@happy-machine

Try this one:

new ApolloLink((operation, forward) => {
      headers = {
        authorization: token
      }
      return forward(operation)
})

Then add it to the link:

link: ApolloLink.from([authLink])

@happy-machine
Copy link
Author

Thanks Dimitri,

Will try this!

Dan

@Zony-Zhao
Copy link

I'm vue apollo new user. I have no idea where should I put this block of code. After I added vue apollo to my project, I didn't see a thing called ApolloLink, but just VueApollo and createApolloClient()

@dmitry
Copy link

dmitry commented May 6, 2021

@Zony-Zhao You should change contents of the createApolloClient function.

@Zony-Zhao
Copy link

@dmitry Thanks. I found #144, which solved my issue perfectly, maybe close this one with duplicate?

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

3 participants