Skip to content
New issue

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

Error to resolve ApolloClients #488

Closed
zoedsoupe opened this issue Mar 7, 2023 · 1 comment · Fixed by #597
Closed

Error to resolve ApolloClients #488

zoedsoupe opened this issue Mar 7, 2023 · 1 comment · Fixed by #597
Labels

Comments

@zoedsoupe
Copy link

Environment

Describe the bug

I have this config at nux.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: "https://pescarte.uenf.br/api",
      },
      local: {
        httpEndpoint: "http://localhost:4000/api",
      },
    },
  },
  // ...
});

and this is my setup at my login page:

<script setup lang="ts">
const query = gql`
  mutation Login($cpf: String!, $password: String!) {
    login(cpf: $cpf, password: $password) {
      token
      user {
        id
        birthdate
        firstName
        middleName
        lastName
        cpf
        role
      }
    }
  }
`;

const { mutate: login } = useMutation<Login>(query, { clientId: "local" });

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 the login form is submitted, it occurs this error:
Uncaught (in promise) Error: No apolloClients injection found, tried to resolve 'local' clientId

Expected behaviour

ApolloClient should be resolved and queries/mutations executed normally

Reproduction

No response

Additional context

If I try to use the default ApolloClient it also fails with the same error.

The whole code can be found at: https://github.com/peapescarte/plataforma

Logs

useApolloClient.ts:27 
        
       Uncaught (in promise) Error: No apolloClients injection found, tried to resolve 'local' clientId
    at resolveClientWithId (useApolloClient.ts:27:11)
    at resolveImpl (useApolloClient.ts:51:24)
    at resolveClient (useApolloClient.ts:66:20)
    at mutate (useMutation.ts:78:20)
    at handleSubmit (acessar.vue:69:3)
    at vee-validate.js:1802:1
resolveClientWithId @ useApolloClient.ts:27
resolveImpl @ useApolloClient.ts:51
resolveClient @ useApolloClient.ts:66
mutate @ useMutation.ts:78
handleSubmit @ acessar.vue:69
(anonymous) @ vee-validate.js:1802
Promise.catch (async)
callWithAsyncErrorHandling @ chunk-3NMN3MUW.js:1590
invoker @ chunk-3NMN3MUW.js:8198
@zoedsoupe zoedsoupe added the bug label Mar 7, 2023
@zoedsoupe
Copy link
Author

Noticed that this address #444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant