Post request Mutation does not work in axios
See original GitHub issueHi, I have a post request mutation done using axios, I am quite sure it is correct, as it works in graphiql. My queries are alright, just the mutations do not work.
errors
POST http://127.0.0.1:5000/graphql 400 (Bad Request)
dispatchXhrRequest @ bundle.js:903
xhrAdapter @ bundle.js:740
dispatchRequest @ bundle.js:1261
Am i missing something? thanks
axios.post("#{graphqlUrl}",{
query: "mutation {
createDevice(input: $input)
}"
variables:
input: device
})
... in schema
type Mutation {
createDevice(input: CreateDeviceInput): Device
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Post mutation to graphql with axios - Stack Overflow
Here's the working request for reference. axios .post(config.apiendpoint, { query: ` mutation addSkill($id:String!, $name:String!, ...
Read more >Node.js mutation example using Axios - monday Community
Hi @kevinmarchese. Here's a sample request to create an item in a board: const axios = require('axios') const body = { query: `...
Read more >How to do GraphQL queries and mutations with Axios - Medium
If your query requires variables as arguments use the template literal syntax demonstrated in the mutation below.
Read more >axios get cookie value from response - You.com - You.com
So the answer should be as simple as specifying the value of the Origin request header in the server.use.cors.origin value. Open side panel....
Read more >Mutations | TanStack Query Docs
Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. ... This will not work in React 16 and earlier....
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 FreeTop 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
Top GitHub Comments
@Paddy-Hamilton @jeanpaulversace You can always validate your query and variables inside GraphiQL:
@benjaminhon Can I close this issue?
@jeanpaulversace if you are using axios, its the ‘data’ property and not the ‘body’ property
here is how i do my axios request
this is my helper function
one case how i use it
one my back end server