We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For the last week I've trying to make this library work within Nuxt 3. I can't seem to access the multple endpoints
nuxt.config.ts
... apollo: { autoImports: true, authType: "XXXXXX", authHeader: "Authorization", tokenStorage: "cookie", proxyCookies: true, clients: { default: { httpEndpoint: "localhost", //placeholder will be replaced at runtime by apollo plugin tokenName: "headerAuth", httpLinkOptions: { credentials: "same-origin", }, }, }, })
apollo.ts
import { provideApolloClient } from "@vue/apollo-composable" import { MultiAPILink } from "@habx/apollo-multi-endpoint-link" export default defineNuxtPlugin((nuxtApp) => { const config = useRuntimeConfig() let client = new ApolloClient({ cache: new InMemoryCache(), link: ApolloLink.from([ new MultiAPILink({ endpoints: { exchange: config.public.api, trade: config.public.apiTwo, }, createHttpLink: () => createHttpLink(), httpSuffix: "", getContext: (endpoint) => { if (endpoint === "exchange") { return { headers: { Authorization: `Bearer ${config.public.token}`, }, } } return { headers: { Authorization: `Bearer ${config.public.token}`, }, } }, }), ]), }) provideApolloClient(client) })
Query
const query = gql` query services { services { ... on Service { name identifier { externalID } serviceType { name identifier { externalID } } } } } ` const { data, error } = await useAsyncQuery(query) if (data.value) (this.data = data), (this.loading = false) if (error.value) (this.error = error.value), console.log("error: " + error?.value) if (data.value) { console.log("Exchange: Services") console.log(data.value) } }
It keeps calling the wrong endpoint. I've also tried useQuery. Any suggestions?
useQuery
The text was updated successfully, but these errors were encountered:
``` const link = ApolloLink.from([ new MultiAPILink({ endpoints: { exchange: config.public.api, trade: config.public.apiTwo, }, createHttpLink: () => createHttpLink(), httpSuffix: "", defaultEndpoint: "exchange", getContext: (endpoint) => { if (endpoint === "exchange") { return { headers: { Authorization: `Bearer ${config.public.token}`, }, } } return { headers: { Authorization: `Bearer ${config.public.tokenTwo}`, }, } }, }), ]) client = $apollo.defaultClient.setLink(link) provideApolloClient(client)
This solves part of the problem, only the 2nd endpoint doesn't get overwritten and it default to the default endpoint localhost in this case
localhost
Sorry, something went wrong.
No branches or pull requests
For the last week I've trying to make this library work within Nuxt 3. I can't seem to access the multple endpoints
nuxt.config.ts
apollo.ts
Query
It keeps calling the wrong endpoint. I've also tried
useQuery
. Any suggestions?The text was updated successfully, but these errors were encountered: