Posts yoPostShopifyGraphQL
Post
Cancel

yoPostShopifyGraphQL

Posting to Shopfiy Via GraphQL

Install:

npm install @benline/yoPostShopifyGraphQL

Usuage:

1
const results = await postShopifyGraphQL(query);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import axios from 'axios';

export const postShopifyGraphQL = (query:any) => {
  return new Promise<any>((resolve, reject) => {
    axios({
      headers: {
        'X-Shopify-Access-Token': process.env.ACCESS_TOKEN,
        'Content-Type': 'application/json',
      },
      url: `https://${process.env.SHOP}.myshopify.com/admin/api/2019-10/graphql.json`,
      method: 'post',
      data: {
        query: query,
      },
    })
    .then(result => {
      resolve(result.data)
    }).catch(error => {
      reject(error)
    })
  });
}
Trending Tags

Trending Tags