Error: "no mutations exist" - Actions
See original GitHub issueVersion 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”
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:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@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