question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: "no mutations exist" - Actions

See original GitHub issue

Version v1.2.0-beta.3 Deployed on Heroku Front-end framework Vue

Expected result: Use action to send a base64 string to an action handler.

The problem When I run the action mutation from the console GraphiQL, it works. But when I try to send a fetch post request from the front-end it fails with:

extensions: {path: “$”, code: “validation-failed”} message: “no mutations exist”

image image Note that the mutation in GraphiQL is tested with the `Authorization ‘Bearer ${token}’ header

Code in the front-end:

import fetch from 'isomorphic-fetch';

const SET_PROFILE_PICTURE = `
  mutation ($base64str: String!, $name: String!, $type: String!) {
    setProfilePicture(base64str: $base64str, name: $name, type: $type) {
      image_path
    }
  }
`;
const fileName = this.file.name;
      const fileType = this.file.type;
      const result = await this.toBase64(this.file).catch(e => Error(e));
      if (result instanceof Error) {
        console.log('Error: ', result.message);
        return;
      }
      const variables = { name: fileName, type: fileType, base64str: result };
      const url = 'https://kw-api-v2-staging.herokuapp.com/v1/graphql';
      const options = {
        method: 'POST',
        headers: {
          'content-type': 'application/json'
        },
        body: JSON.stringify({
          query: SET_PROFILE_PICTURE,
          variables: variables
        })
      };
      console.log("variables", variables);
      console.log("SET Profile PIC", SET_PROFILE_PICTURE);

      fetch(url, options)
        .then(res => res.json())
        .then(res => {
          console.log(res)
          this.file = null;
        })
        .catch(err => {
          console.log(err);
        });

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Overdozedcommented, Jun 3, 2020

check you provide HASURA_GRAPHQL_UNAUTHORIZED_ROLE env var without any quotes from .env file. In my case hasura logs said {“x-hasura-role”:“"public"”} => double double quotes. This cause you really have no mutation/queries for your unauthorized role.

Hope this helps.

1reaction
hgiasaccommented, Apr 13, 2020

@costas90 Did you debug returned role from auth webhook? I think it returns anonymous role that isn’t allowed to run this action. Moreover, I don’t see where you input authorization token header in your code

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible customize Hasura mutation/query Error messages?
My question is, is it possible to configure this error message? Because here, the role don't have the permission to do mutation. So...
Read more >
Resolving a mutation with errors | Lift-off IV - Apollo GraphQL
Handling the error case. As we saw in the REST API, it's possible to get a 404 Not Found response when trying to...
Read more >
Top GraphQL Errors and How to fix them
Technically this error came out of using a field which doesn't exist (either due to Auth or schema not really having the field)....
Read more >
Mutations | TanStack Query Docs
error - If the mutation is in an error state, the error is available via the error property. data - If the mutation...
Read more >
Create custom GraphQL mutations using graphql-ruby as well ...
In part two of this series, we'll learn how to write standard and custom mutations in GraphQL using graphql-ruby and reusable mutations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found