Miss any of our Open RFC calls?Watch the recordings here! »

shopify-graphql-mutationer

1.0.20 • Public • Published

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)));
 

Install

npm i shopify-graphql-mutationer

DownloadsWeekly Downloads

34

Version

1.0.20

License

ISC

Unpacked Size

38.2 kB

Total Files

41

Last publish

Collaborators

  • avatar