TypeScript 1.0 Compatibility
If you are migrating from <1.0, we created a new plugin called typescript-compatibility
that generates backward compatibility for the typescript-operations
and typescript-react-apollo
plugins.
It generates types that are pointing to the new form of types. It supports most of the use-cases.
Installation
Using yarn
API Reference
noNamespaces
type: boolean
default: false
Does not generate TypeScript namespace
s and uses the operation name as prefix.
Usage Examples
strict
type: boolean
default: false
Make sure to generate code that compatible with TypeScript strict mode.
Usage Examples
preResolveTypes
type: boolean
default: false
Avoid using Pick
in typescript-operations
and make sure to optimize this package as well.
scalars
type: ScalarsMap
Extends or overrides the built-in scalars and custom GraphQL scalars to a custom type.
namingConvention
type: NamingConvention
default: change-case-all#pascalCase
Allow you to override the naming convention of the output.
You can either override all namings, or specify an object with specific custom naming convention per output.
The format of the converter must be a valid module#method
.
Allowed values for specific output are: typeNames
, enumValues
.
You can also use "keep" to keep all GraphQL names as-is.
Additionally you can set transformUnderscore
to true
if you want to override the default behavior,
which is to preserves underscores.
Available case functions in change-case-all
are camelCase
, capitalCase
, constantCase
, dotCase
, headerCase
, noCase
, paramCase
, pascalCase
, pathCase
, sentenceCase
, snakeCase
, lowerCase
, localeLowerCase
, lowerCaseFirst
, spongeCase
, titleCase
, upperCase
, localeUpperCase
and upperCaseFirst
See more
typesPrefix
type: string
default: ``
Prefixes all the generated types.
Usage Examples
typesSuffix
type: string
default: ``
Suffixes all the generated types.
Usage Examples
skipTypename
type: boolean
default: false
Does not add __typename to the generated types, unless it was specified in the selection set.
Usage Examples
nonOptionalTypename
type: boolean
default: false
Automatically adds __typename
field to the generated types, even when they are not specified
in the selection set, and makes it non-optional
Usage Examples
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