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

@stackworx/relay-network

v3.0.0-alpha.0

Published

A Relay Network layer built on ky, with support for file uploads (GraphQL multipart request) and incremental delivery (@defer/@stream).

Downloads

99

Readme

Relay Network

CI npm license

A Relay Network layer built on ky.

Features:

  • Queries over GET, mutations over POST
  • File uploads via the GraphQL multipart request spec
  • Incremental delivery (@defer / @stream) over multipart/mixed, normalized to Relay-compatible payloads
  • Configurable retries, timeouts, and logout handling
  • Request/response/error hooks passed through to ky

Installation

npm add @stackworx/relay-network ky relay-runtime

ky and relay-runtime are peer dependencies.

Usage

import {Network} from "relay-runtime";
import {createFetchQuery} from "@stackworx/relay-network";

const network = Network.create(
  createFetchQuery({
    url: "http://localhost/graphql",

    // Optional
    timeout: 10000,

    // Optional. Queries are retried; mutations never are.
    retry: {
      statusCodes: [503],
      methods: ["get"],
      limit: 2,
    },

    // Optional. Return true when the response means the user should be logged
    // out. Default: response.status === 403
    logoutCheck(response) {
      return response.status === 403;
    },

    // Optional. React to expired credentials, e.g. clear the store or tokens.
    async handleLogout() {
      // ...
    },
  }),
);

Configuration

| Option | Type | Description | | --------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | url | string \| (() => Promise<string>) | GraphQL endpoint, or a function resolving to one. | | headers | Record<string, string \| undefined> \| ((request) => Promise<...>) | Static headers, or a function producing them per request. | | timeout | ky timeout | Request timeout. | | retry | ky retry | Retry config. Applied to queries only, never mutations. | | logoutCheck | (response: Response) => boolean | Decide whether a response means the user should be logged out. Default: status === 403. | | handleLogout | () => Promise<void> \| void | Called when logoutCheck returns true. | | deleteDataIfError | boolean | When a payload has both data and errors, drop data so Relay routes it to onError. Useful for servers that return {} on failed mutations. | | allowApplicationJsonContentType | boolean | Accept application/json responses in addition to application/graphql-response+json. | | hooks | ky Hooks | ky lifecycle hooks (beforeRequest, afterResponse, beforeError, ...). Merged ahead of the built-in logout beforeError hook. |

Incremental delivery (@defer / @stream)

Some GraphQL servers send incremental delivery payloads in the RFC-style shape:

{
  "incremental": [
    {
      "data": {"exportName": "Kolomela 63.5%, 8mm Fine Ore"},
      "label": "test",
      "path": ["products", 1]
    }
  ],
  "hasNext": false
}

Relay Runtime (17.x) treats a payload as an incremental patch only if it has top-level label and path. If the RFC-style payload is forwarded as-is, Relay can warn that there was "No data returned" (because there is no top-level data).

This library normalizes the RFC-style payload into Relay-compatible patch payloads before calling sink.next(...):

{
  "data": {"exportName": "Kolomela 63.5%, 8mm Fine Ore"},
  "label": "test",
  "path": ["products", 1]
}

Using with MSW

When mocking multipart/mixed responses with MSW, see https://github.com/mswjs/msw/issues/1388#issuecomment-1344382071.

References

Contributing

Contributions are welcome! See CONTRIBUTING.md.

License

MIT © Stackworx