How to make mutation Graghql request (Node, Express)

Highlighted
New Member
2 0 0

Trying to make a simple API call to my own node.js app that upload new products to my shopify store without manually uplaod the csv file.

Here i try to make a simple mutation request to try creating a new customer, just to try if this mutation method work.

require('isomorphic-fetch');
app.get("/shop-info", (req, res) => {
	fetch("https://<my-store-id>.myshopify.com/admin/api/2020-07/graphql.json", {
		method: "POST",
		headers: {
			"Content-Type": "application/json",
			"X-Shopify-Access-Token": <myAccessToken>
		},
		body: JSON.stringify({
			mutation: `{
				customrCreate(
					input:{
						firstName: "dude",
						lastName: "Dude",
						email: "w@w.com"
					}
				)
			}
			{
				customer{
					id
					firstName
					lastName
					email
				}
			}`
		})
	})
	.then(result => {
		return result.json();
	})
	.then(data => {
		console.log("data returned:\n", data);
		res.send(data);
	});
});

but NOPE, it returns:

data returned:
 { errors: { query: 'Required parameter missing or invalid' } }

 

i followed these guides:

https://shopify.dev/tutorials/graphql-with-node-and-express

where the guide only provide the query method, which i can do a query but not a mutation.

So i try dig deeper

https://www.shopify.com/partners/blog/shopify-graphql-learning-kit 

Still, doesn't seem to work

0 Likes
Highlighted
Shopify Staff
Shopify Staff
145 19 25

Hey @argonian 

Might just be a typo, you have 

customrCreate

 

Kevin_A | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes