I have this config on nuxt.config.ts
:
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
apollo: {
autoImports: true,
authType: "Bearer",
authHeader: "Authorization",
tokenStorage: "cookie",
proxyCookies: true,
clients: {
default: {
httpEndpoint: "...",
},
local: {
httpEndpoint: "...",
},
},
},
// ...
});
Then in my login page I use useMutation
, that way:
<script setup lang="ts">
const query = gql`...`;
const { mutate: login } = useMutation<Login>(query);
async function handleSubmit(values) {
const { onLogin } = useApollo();
const { cpf, password } = values;
const variables = { cpf, password };
const result = await login(variables);
console.log(result);
}
</script>
However when I do try to call login
callback, application throws this error:
Uncaught (in promise) Error: No apolloClients injection found, tried to resolve 'default' clientId
Firtly I installed @nuxtjs/apollo
, then when I tried to execute a query or mutation I received an error saying that the module @vue/apollo-composable
was mising.
Then I adressed this github issue: https://github.com/nuxt-modules/apollo/issues/444 and installed the missing module with npm i --force @vue/apollo-composable
. Now I'm having this error on resolving Apollo clients