This library returns all products or ids from a Shopify collection or product publication using the GraphQL endpoint. It automatically handles pagination.
Inside of your project, do:
yarn add @originalfunko/shopify-fetcher
Simply include the library:
const shopifyFetcher = require('shopify-fetcher');
Initialize your config settings:
shopifyFetcher.init({
SHOPIFY_API_URI: '<API_URI>',
SHOPIFY_API_TOKEN: '<API_TOKEN>',
});
Then call it as needed:
let productsResult = await shopifyFetcher.collection.fetchIt(id);
let productIds = await shopifyFetcher.collection.parseIt(id, productsResult);
products = products.concat(productIds);
Beyond the SHOPIFY_API_URI
and SHOPIFY_API_TOKEN
settings (which will inherit process.env.SHOPIFY_API_URI
and process.env.SHOPIFY_API_TOKEN
if available), here is the complete list of settings:
shopifyFetcher.init({
SHOPIFY_API_URI: '<API_URI>',
SHOPIFY_API_TOKEN: '<API_TOKEN>',
SHOPIFY_API_RATE_LIMIT_PERCENTAGE: 30,
SHOPIFY_API_RATE_LIMIT_MIN: 5000,
SHOPIFY_API_RATE_LIMIT_MAX: 10000,
SHOPIFY_API_GRAPHQL_MEDIA: 7,
SHOPIFY_API_GRAPHQL_PRODUCTS: 15,
SHOPIFY_API_GRAPHQL_VARIANTS: 10,
});