shopify-graphql-mutationer
v1.0.20
Published
> Shopify GraphQL Mutation
Downloads
3
Readme
shopify-graphql-mutationer
Shopify GraphQL Mutation
Installation
This is an update to the package
shopify-graphql-mutationer
To install this package, you can run
npm install --save shopify-graphql-mutationer
Or
yarn add shopify-graphql-mutationer
Usage
- Simple query
import GraphQL from "shopify-graphql-mutationer";
const GraphQLClient = new GraphQL("domain", "access-token");
const query = `query { shop { id } }`;
GraphQLClient
.request(query)
.then(data => console.log(JSON.stringify(data.shop, null, 2)))
.catch(error => console.log(JSON.stringify(error, null, 2)));
- Simple mutation
import GraphQL from "shopify-graphql-mutationer";
const GraphQLClient = new GraphQL("domain", "access-token");
const mutation = `
mutation collectionCreate($input: CollectionInput!) {
collectionCreate(input: $input) {
collection {
id
}
}
}
`;
GraphQLClient
.request(mutation, {
input: {
descriptionHtml: "Collection was created from GraphQL",
title: "GraphQL Collection",
},
})
.then(data => console.log(JSON.stringify(data, null, 2)))
.catch(error => console.log(JSON.stringify(error, null, 2)));