gridsome-source-printful

0.1.0 • Public • Published

Gridsome Source for Printful

Source plugin for fetching data from Printful into Gridsome.

Install

npm install --save gridsome-source-printful

or

yarn add gridsome-source-printful

How to use

// In your gridsome.config.js
plugins: [
  {
    use: 'gridsome-source-printful',
    options: {
      objectTypes: ['SyncProduct', 'WarehouseProduct', 'Country', 'TaxRate'],
      apiKey: 'xxxxxxxxx',
      // optional params
      downloadFiles: true,
      imageDirectory: 'printful_images',
    },
  },
];

if downloadFiles is true the plugin will download all assets associated to fields image and images into imageDirectory.

How to query and filter

For example, you can query the product nodes created from Printful with the following:

query {
  allPrintfulProduct {
    edges {
      node {
        id
        external_id
        name
        slug
        thumbnail_url
        thumbnail_img (width: 100 height: 100)
        __typename
        variants {
          id
          variant_id
          external_id
          sync_product_id
          retail_price
          currency
          name
          sku
          files {
            id
            filename
            thumbnail_url
          }
        }
      }
    }
  }
}
 

and you can filter specific node using this:

query product($id: String!) {
  printfulProduct(id: $id) {
    id
    external_id
    name
  }
}

Another example with the countries:

query {
  allPrintfulCountry {
    totalCount
    edges {
      node {
        id
        name
        code
        states {code name}
      }
    }
  }
}

Documentation

The official Printful API documentation is here

Thanks

This plugin has been:

Package Sidebar

Install

npm i gridsome-source-printful

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

10.4 kB

Total Files

3

Last publish

Collaborators

  • svengau