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

fastify-shopify-graphql-proxy

v4.0.0

Published

Fastify plugin to proxy requests to the Shopify GraphQL API.

Downloads

18

Readme

fastify-shopify-graphql-proxy

License: Hippocratic 3.0 code style: prettier npm version codecov Main WorkFlow CodeQL WorkFlow

fastify-shopify-graphql-proxy is a plugin for the Fastify framework that is based on koa-shopify-graphql-proxy. It allows for proxying of GraphQL requests from an embedded Shopify app to Shopify's GraphQL API.

Any POST request made to /graphql will be proxied to Shopify's GraphQL API and the response will be returned.

Supported Fastify versions

  • Fastify v4.x

Supported Node.js versions

The latest versions of the following Node.js versions are tested and supported.

  • 16
  • 18

Quick Start

Install the package using npm:

npm i --save-exact fastify-shopify-graphql-proxy

or yarn:

yarn add fastify-shopify-graphql-proxy

or pnpm:

pnpm add --save-exact fastify-shopify-graphql-proxy

Code Examples

Custom App

If you are creating a Custom Shopify app, you can skip over the auth step and provide the shop URL and accessToken.

import shopifyGraphQLProxy, { ApiVersion } from "fastify-shopify-graphql-proxy";
import Fastify from "fastify";

const server = Fastify({
  logger: true,
});

await server.register(shopifyGraphQLProxy, {
  shop: "https://my-shopify-store.myshopify.com",
  version: ApiVersion.Stable,
  accessToken: "SHOPIFY_API_ACCESS_TOKEN",
});

server.listen({ port: 3000 }, function (err, address) {
  if (err) {
    server.log.error(err);
    process.exit(1);
  }

  server.log.info(`server listening on ${address}`);
});

Public App (Not currently possible)

This Fastify plugin will get the shop url and AccessToken from the current session of the logged-in store. Note: You will need to use fastify-session for this to work.

import fastifyCookie from "fastify-cookie";
import fastifySession from "@fastify/session";
import createShopifyAuth from "fastify-shopify-auth";
import shopifyGraphQLProxy, { ApiVersion } from "fastify-shopify-graphql-proxy";
import Fastify from "fastify";

const server = Fastify({
  logger: true,
});

await server.register(fastifyCookie);
await server.register(fastifySession, { secret: "a secret with a minimum length of 32 characters" });

await server.register(
  await createShopifyAuth({
    /* your config here */
  }),
);

await server.register(shopifyGraphQLProxy, {
  version: ApiVersion.Stable, // API Version "2022-04"
});

server.listen({ port: 3000 }, function (err, address) {
  if (err) {
    server.log.error(err);
    process.exit(1);
  }

  server.log.info(`server listening on ${address}`);
});

API

shopifyGraphQLProxy(opts)

Options:

  • shop (Optional): a string value that is the Shopify URL for your store. Gets value from session if available.
  • accessToken (Optional): a string value that is the Custom App API Key. Gets value from session if available.
  • version (Optional): Shopify GraphQL version (example: "2022-04").
  • prefix (Optional): You can set a custom path for the shopifyGraphQLProxy GraphQL endpoint by specifying a route prefix.

Here are all the Shopify API GraphQL versions that can be imported from the enum ApiVersion and used such as ApiVersion.April22:

October22 = "2022-10"
July22 = "2022-07"
April22 = "2022-04"
January22 = "2022-01"
October21 = "2021-10"
Stable = "2022-10"
Unstable = 'Unstable'
Unversioned = 'unversioned'