README
urql-generic-requester
GraphQL Codegen Generic SDK Requeter creator for URQL Client
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. If you have then already installed you don't have to add them again
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)