GraphQL Codegen Generic SDK Requester for URQL
- 0 Deps
- unminified
dist
(easier to contribute to and fix while using)
- Doesn't support
subscriptions
(yet)
I don't know of any other shortcomings, feel free to raise an issue if you do.
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
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
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);