Is it possible to set up dynamically the endpoint? #1405
Unanswered
FilipePrates
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wish to create a new apolloClient using data gathered by the Vue app after the initial config, and set it as a possible Client on the ApolloProvider like in this example The difference is that I wish to gather from the user what the intended httpEndpoint is to feed the createApolloClient function, but every example I see this happens before the App is setup. Can I delay the Apollo Config setup until I decide is time to set it up?
Using Nuxt.js/Vue.js Graphql Apollo Neo4j stack, and the Apollo config is beeing done in nuxt.config.js:
`
// Modules: https://go.nuxtjs.dev/config-modules
modules: ["@nuxtjs/apollo"],
apollo: {
clientConfigs: {
default: {
httpEndpoint,
wsEndpoint,
tokenName: AUTH_TOKEN,
persisting: false,
websocketsOnly: false,
ssr: false,
// cache: new InMemoryCache({ fragmentMatcher }),
},
},
includeNodeModules: true,
},
`
In this case the httpEndpoint is beeing set on the same file, above it:
if (process.env.VUE_APP_ENV == "staging") { httpEndpoint = "https://stagingURL/graphql"; wsEndpoint = "wss://stagingURL/graphql"; } else if (process.env.VUE_APP_ENV == "testing") { httpEndpoint = "https://testsURL/graphql"; wsEndpoint = "wss://testsURL/graphql"; } else if (process.env.NODE_ENV == "production") { httpEndpoint = "https://productionURL/graphql"; wsEndpoint = "wss://productionURL/graphql"; }
But what I really want now is for the user to fill a form with a '/graphql' endpoint of his, and set this given URL as the ApolloDriver endpoint. Ideas on how to do that?
Beta Was this translation helpful? Give feedback.
All reactions