Package name | Weekly Downloads | Version | License | Updated |
---|---|---|---|---|
@graphql-codegen/urql-introspection | Aug 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
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**\/*.tsx'],
generates: {
'path/to/file.json': {
plugins: ['urql-introspection'],
config: {
module: 'commonjs'
},
},
},
};
export default config;
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
Usage Examples
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**\/*.tsx'],
generates: {
'path/to/file.json': {
plugins: ['urql-introspection'],
config: {
useTypeImports: true
},
},
},
};
export default config;
includeScalars
type: boolean
default: false
Includes scalar names (instead of an Any
replacement) in the output when enabled.
Usage Examples
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**\/*.tsx'],
generates: {
'path/to/file.json': {
plugins: ['urql-introspection'],
config: {
includeScalars: true
},
},
},
};
export default config;
includeEnums
type: boolean
default: false
Includes enums (instead of an Any
replacement) in the output when enabled.
Usage Examples
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**\/*.tsx'],
generates: {
'path/to/file.json': {
plugins: ['urql-introspection'],
config: {
includeEnums: true
},
},
},
};
export default config;
includeInputs
type: boolean
default: false
Includes all input objects (instead of an Any
replacement) in the output when enabled.
Usage Examples
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**\/*.tsx'],
generates: {
'path/to/file.json': {
plugins: ['urql-introspection'],
config: {
includeInputs: true
},
},
},
};
export default config;
includeDirectives
type: boolean
default: false
Includes all directives in the output when enabled.
Usage Examples
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**\/*.tsx'],
generates: {
'path/to/file.json': {
plugins: ['urql-introspection'],
config: {
includeDirectives: true
},
},
},
};
export default config;