https://github.com/iamskok/gatsby-plugin-shopify-metafields
Add Storefront Visibility Metafields 🛍
https://github.com/iamskok/gatsby-plugin-shopify-metafields
admin-api ecommerce gatsby gatsby-plugin shopify storefront-api
Last synced: 3 months ago
JSON representation
Add Storefront Visibility Metafields 🛍
- Host: GitHub
- URL: https://github.com/iamskok/gatsby-plugin-shopify-metafields
- Owner: iamskok
- Created: 2019-06-04T23:16:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-26T02:50:14.000Z (about 5 years ago)
- Last Synced: 2025-04-14T19:13:15.714Z (3 months ago)
- Topics: admin-api, ecommerce, gatsby, gatsby-plugin, shopify, storefront-api
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
gatsby-plugin-shopify-metafieldsPlugin to add Storefront Visibility Metafields via [Shopify Admin API](https://help.shopify.com/en/api/graphql-admin-api). This plugin makes `metafields` property accessable via [Shopify Storefront API](https://help.shopify.com/en/api/storefront-api/getting-started).

> You can use the Storefront API to read metafields for products and product variants. Metafields are useful for storing specialized information, such as part numbers or additional variant options. The Storefront API lets you access and use that data on the custom storefront.
More in-depth explanation can be found in [Retrieving metafields from Storefront API](https://help.shopify.com/en/api/custom-storefronts/storefront-api/guides/metafields).
## Install
```sh
yarn add gatsby-plugin-shopify-metafields
```## How to use
```js
{
resolve: `gatsby-plugin-shopify-metafields`,
options: {
// The domain name of your Shopify shop. This is required.
// Example: 'gatsby-shopify' if your Shopify address is
// 'gatsby-shopify.myshopify.com'.
shopName: `gatsby-shop`,
// An Admin API Key to your Shopify shop. This is required.
// You can generate an access token in the "Manage private apps" section
// of your shop's Apps settings.
// See: https://help.shopify.com/en/api/graphql-admin-api/getting-started#authentication
adminAPIKey: `03h7545db6f32a0dd1b0agupje551970`,
// An Admin API Password to your Shopify shop. This is required.
adminPassword: `47u3929dubj32489dhbbsahdjasdgjas`,
// A list of MetafieldStorefrontVisibility records to whitelist.
// It's a good practice to keep the list of metafields in a separate
// 'json' file and require it in 'gatsby-config.js' to keep it concise.
inputs: [
{
"namespace": "global",
"key": "featured",
"ownerType": "PRODUCT"
},
{
"namespace": "spain",
"key": "sale",
"ownerType": "COLLECTION"
},
...
],
// Set verbose to true to display a warning or an error output.
// This prints which MetafieldStorefrontVisibility record.
// was already whitelisted or if there is an error
// Defaults to true.
verbose: true,
// Disable plugin.
// In most scenarios MetafieldStorefrontVisibility has to be whitelisted just once.
// In this case you can disable this plugin and shave off couple of seconds from your build.
// Defaults to 'true'.
updateMetafields: true
}
}
```