Replace Apollo Provider after initialization #999
Replies: 6 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}`
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
did you find the solution? |
Beta Was this translation helpful? Give feedback.
-
@gaoxianglyx for now I've stuck to the solution mentioned above to set the context object, do you have any other ideas? |
Beta Was this translation helpful? Give feedback.
-
I think using apollo context is the right way to go. |
Beta Was this translation helpful? Give feedback.
-
@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. |
Beta Was this translation helpful? Give feedback.
-
@ivansieder I find the right way to set context,here is the example |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions