npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@andvea/shopify-graphql-client

v1.1.1

Published

This is a JavaScript module that allows you to invoke Shopify's GraphQL API with Node without having to worry about all the tedious stuff like retries, throttling, backoff time and more. The purpose is to abstract all the [best practices](https://shopi

Downloads

4

Readme

Shopify GraphQL Client

This is a JavaScript module that allows you to invoke Shopify's GraphQL API with Node without having to worry about all the tedious stuff like retries, throttling, backoff time and more. The purpose is to abstract all the best practices necessary for a healthy intensive use of the Shopify GraphQL API, so that you can take care of the rest.

Here you can find a list of the major benefits. Please note that some of them are still work in progress.

  • Errors catching: sometimes there's a mistake to fix, sometimes it's just a matter of time. This library recognizes these two types of errors based on Shopify's response and abstracts their complexity with simple responses and automation mechanisms.
  • Backoff timing: the rate of your requests is automatically adjusted based on response's API usage metadata for smoother distribution, in order to reduce the throttled requests.
  • Automatic retry: you can configure the library to automatically retry trotthled requests.
  • Queue: your requests are automatically placed in a FIFO queue which guarantees the order of execution.
  • HTTP/2 support: all the requests are made via HTTP/2 and the session remains active as long as the queue is not empty. It's a mechanism that allows you to save time, especially with many requests in the queue.
  • No dependencies: a lightweight solution that minimizes potential conflicts
  • Cache (Work in progress)
  • Metrics (Work in progress)

Table of Contents

Installation

You can install the library via npm

npm install @andvea/shopify-graphql-client --save

Usage

This is a basic example of using the library:

import {ShopifyGraphQL} from '@andvea/shopify-graphql-client';

var shopifyGraphQL =
  new ShopifyGraphQL({
    apiEndpoint: 'https://test.myshopify.com/admin/api/2023-04/graphql.json',
    apiKey: 'shpca...b32',
    retryThrottles: true,
    maxConcurrentRequests: 5
  });

try {
  var shopifyResponse = 
    await shopifyGraphQL.request(`{ 
      shop { 
        id 
      } 
    }`);
    
  console.log(shopifyResponse);
} catch(reqErr) {
  console.log('Something went wrong!');
  console.log(reqErr);
}

Parameters

  • apiEndpoint: full API endpoint, eg https://test.myshopify.com/admin/api/2023-04/graphql.json
  • apiKey: the shop's API key
  • retryThrottles: whether throttled requests should be automatically retried
  • maxConcurrentRequests: how many requests can be sent at the same time. This concurrency capacity refers to how many requests can be sent even if Shopify hasn't responded yet

Tests

To get an overview of tests, read the related section in the Contributing guide.

Getting help

Feel free to open an issue if you have any problem.

Contribution

Contributions are more than welcome. To learn more about, read the Contributing guide.

Credits

My thanks go to my friends at Uppa. Aiming to build a better world is an attitude I learnt from them: Chiara B., Chiara R., Claudia L.G., Daniela M., Francesca G., Giulia B., Lidia D., Lorenzo B., Lorenzo C., Pierpaolo D.M., Sergio C.N., Virginia V.