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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thor-commerce/graphql-codegen-preset

v1.0.2

Published

GraphQL Codegen preset helpers for Thor Commerce APIs

Readme

@thor-commerce/graphql-codegen-preset

GraphQL Codegen helpers for Thor Commerce Admin and Storefront APIs.

Installation

npm install -D @graphql-codegen/cli graphql @thor-commerce/graphql-codegen-preset

@thor-commerce/graphql-codegen-preset does not ship the graphql-codegen binary. Install @graphql-codegen/cli in the consuming project and run the CLI from that project.

graphql.config.ts

import {
  ApiType,
  ClientType,
  thorCommerceApiProject,
} from "@thor-commerce/graphql-codegen-preset";

export default {
  projects: {
    admin: thorCommerceApiProject({
      apiType: ApiType.Admin,
    }),
    storefront: thorCommerceApiProject({
      apiType: ApiType.Storefront,
      client: ClientType.Apollo,
      outputDir: "./src/storefront/types",
      documents: ["./src/storefront/**/*.{ts,tsx}"],
    }),
  },
};

package.json

{
  "scripts": {
    "graphql-codegen": "graphql-codegen --config graphql.config.ts"
  }
}

Generated files

For each API, the preset generates:

  • <api>.schema.json
  • <api>.types.d.ts
  • <api>.generated.d.ts

Set declarations: false if you want .ts outputs instead of .d.ts.

Schema Fetching

Schema fetching is not tenant-specific. By default the preset reads from:

  • https://api.thorcommerce.io/admin/graphql/schema.graphql
  • https://api.thorcommerce.io/storefront/graphql/schema.graphql

You only need baseUrl if you want to point codegen at a different environment.

Client Modes

  • client: ClientType.Thor is the default and uses the Thor preset output.
  • client: ClientType.Apollo generates typescript-operations plus typed-document-node output in <api>.generated.*.

Using With @thor-commerce/graphql-client

If you want to use the generated types with @thor-commerce/graphql-client, prefer client: ClientType.Apollo.

That mode gives you operation result and variable types you can feed into request() or requestOrThrow() on the runtime client:

import {createAdminGraphQLClient} from "@thor-commerce/graphql-client";
import type {
  GetOrdersQuery,
  GetOrdersQueryVariables,
} from "./types/admin.generated";

const client = createAdminGraphQLClient({
  tenant: "demo",
  apiKey: process.env.THOR_ADMIN_API_KEY!,
});

const GET_ORDERS_QUERY = `#graphql
  query GetOrders($first: Int!) {
    orders(first: $first) {
      nodes {
        id
      }
    }
  }
`;

const data = await client.requestOrThrow<
  GetOrdersQuery,
  GetOrdersQueryVariables
>(GET_ORDERS_QUERY, {
  variables: {first: 10},
});