urql-generic-requester
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

urql-generic-requester

GraphQL Codegen Generic SDK Requester for URQL

Features

  • 0 Deps
  • unminified dist (easier to contribute to and fix while using)

Shortcomings

  • Doesn't support subscriptions (yet)

I don't know of any other shortcomings, feel free to raise an issue if you do.

About

This package is to work with graphql-code-generator's generic sdk configuration which generates the sdk with a dynamic requester in place. Apollo supports it directly and so does other graphql solutions. This one is for urql/core

generates:
  sdk.ts:
    plugins:
      - typescript
      - typescript-generic-sdk

Install

The package depends on graphql and urql, so do install them. Ignore if you've already have them installed.

npm i urql-generic-requester graphql urql
# or
yarn add urql-generic-requester graphql urql

Usage

The library is typesafe and will infer types from urql's response structure for you to use as is.

import { createUrqlRequester } from "urql-generic-requester";
import { createClient } from "urql";

// get the sdk from the generated file from graphql-codegen
import { getSdk } from "./sdk.ts";

const client = createClient({
  // ... urql client config and exchanges
});

const requestHandler = createUrqlRequester(client);

const sdk = getSdk(requestHandler);

License

MIT

Package Sidebar

Install

npm i urql-generic-requester

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

6.81 kB

Total Files

6

Last publish

Collaborators

  • barelyreaper