Urql Introspection for Schema Awareness

Package nameWeekly DownloadsVersionLicenseUpdated
@graphql-codegen/urql-introspectionDownloadsVersionLicenseAug 8th, 2022

Installation

yarn add -D @graphql-codegen/urql-introspection

How to use?

// generated by the plugin
import schema from './generated-introspection.json'
const cache = cacheExchange({ schema })

This plugin generates an introspection file for Schema Awareness feature of Urql Cache Exchange

You can read more about it in urql documentation: https://formidable.com/open-source/urql/docs/graphcache/schema-awareness.

Urql Introspection plugin accepts a TypeScript / JavaScript or a JSON file as an output (.ts, .tsx, .js, .jsx, .json).

Both in TypeScript and JavaScript a default export is being used.

The output is based on the output you choose for the output file name.

Config API Reference

module

type: string (values: commonjs, es2015) default: es2015

Compatible only with JSON extension, allow you to choose the export type, either module.exports or export default. Allowed values are: commonjs, es2015.

Usage Examples

generates:
  path/to/file.json:
    plugins:
      - urql-introspection
    config:
      module: commonjs
useTypeImports

type: boolean default: false

Will use import type {} rather than import {} when importing only types. This gives compatibility with TypeScript's "importsNotUsedAsValues": "error" option

includeScalars

type: boolean default: false

Includes scalar names (instead of an Any replacement) in the output when enabled.

includeEnums

type: boolean default: false

Includes enums (instead of an Any replacement) in the output when enabled.

includeInputs

type: boolean default: false

Includes all input objects (instead of an Any replacement) in the output when enabled.

includeDirectives

type: boolean default: false

Includes all directives in the output when enabled.

Last updated on August 10, 2022