0.1.0 • Published 2 months ago

shopify-bulk-export v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

shopify-data-export

A package to help you bulk export data from Shopify's async Bulk Operation API.

Usage

Install the package:

pnpm install shopify-bulk-export

Then, import the package and use the default exported function to run a query:

import bulkExport from 'shopify-bulk-export'

interface Product {
  id: string
  title: string
}

// The function accepts a generic, which will be the type of the nodes returned:
const data = await bulkExport<Product>({
  query: 'query Products { products { edges { node { id title } } } }',
  store: {
    accessToken: '',
    name: ''
  }
})

You can also pass a TypedDocumentNode query if you use the GraphQL Code Generator for example:

import bulkExport from 'shopify-bulk-export'
import { ProductsQueryDoc } from './generated'

const data = await bulkExport({
  query: ProductsQueryDoc,
  store: {
    accessToken: '',
    name: ''
  }
})

If your query has variables (for example a search query), you can pass these in and they will be replaced in your query:

import bulkExport from 'shopify-bulk-export'

const query = `<some-runtime-query>`

const data = await bulkExport({
  query: 'query Products ($query: String!) { products (query: $query) { edges { node { id title } } } }',
  store: {
    accessToken: '',
    name: ''
  },
  variables: {
    query
  }
})