Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace Apollo Provider after initialization #999
Comments
The "best" (the best among the probably ugliest) solution I was able to find is the one to add the context to the $query property of the apollo component option as a function which seems to execute it each time and allows to access the Vue instance props: apollo: {
$query: {
context() {
return {
headers: {
"Some-Token": `${this.myTokenProp}`
}
}
}
}
} |
did you find the solution? |
@gaoxianglyx for now I've stuck to the solution mentioned above to set the context object, do you have any other ideas? |
I think using apollo context is the right way to go. |
@Akryum thank you. Could it be an idea to expose a function to set the context dynamically at runtime? Cause this way we currently have to set the context at each call. |
@ivansieder I find the right way to set context,here is the example |
Is your feature request related to a problem? Please describe.
Our Apollo HTTP Link depends on some Vue props being passed down, as we need to add a widget-token to the headers on each request.
Describe the solution you'd like
Either being able to initialize vue-apollo inside the created hook with the appropriate props or simply replacing the http link from within the created hook after the apollo provider has been initialized and installed would be ideal.