logaretm / villus

🏎 A tiny and fast GraphQL client for Vue.js
https://villus.dev
MIT License
790 stars 31 forks source link

Mutation response undefined #180

Open ludgart opened 1 year ago

ludgart commented 1 year ago

Hello,

I'm following the documentation page https://villus.logaretm.com/guide/mutations/#handling-errors but I'm receiving an undefined response from the mutation.

My method

    login(test) {
      const {execute} = useMutation(loginMutation);

      return execute({
        test: test,
      }).then((result) => {
        console.log("result", result);
      }).catch((error) => {
        console.error(error);
      });
    },

Response from the server

{"errors":[{"message":"test is invalid.","path":["login"],"extensions":{"code":"INTERNAL_SERVER_ERROR","exception":{"message":"test is invalid.","path":["login"],"stacktrace":["GraphQLError: test is invalid.","    at login (file:///****/AuthModule.js:113:17)","    at processTicksAndRejections (node:internal/process/task_queues:96:5)","    at async file:///***/@graphql-tools/batch-execute/index.mjs:354:36","    at async Promise.all (index 0)","    at async DataLoader.batchExecuteLoadFn [as _batchLoadFn] (file:///****/@graphql-tools/batch-execute/index.mjs:352:25)"]}}}],"data":null}

Result from the console

test {data: undefined, error: undefined}

Versions:

Is this an issue or what I'm doing wrong?

Thanks in advance!

logaretm commented 1 year ago

Not sure what is going on here. Perhaps the server is wrapping the response object? Can you point me to the API if it is public?