Skip to content

v0.18.0

Compare
Choose a tag to compare
@piglovesyou piglovesyou released this 19 May 01:31
· 109 commits to main since this release

v0.18.0 release馃帀

v0.18.0 fixed #60, which pointed out duplicated generation of schema types are in trouble, especially in production-size GraphQL schema possibly having massive stitched GrpahQL types.

The types, generated by the typescript plugin, are now all in graphql-let/__generated__/__types__ and shared by the other outputs. This requires you to migrate to use v0.18.0.

Many users realize this release. Thank you for the awesome Preset, @dotansimha. Thanks for your support, @StevenLangbroek, @acao.

Frame 11

Migration guide to v0.18.0

1. Install additional peer dependency

Please install @graphql-codegen/import-types-preset as an additional peer dependency.

yarn add -D @graphql-codegen/import-types-preset

2. Change .graphql-let.yml

Please change your config file as below. schemaEntrypoint became obsolete since it's always graphql-let/__generated__/__types__ from v0.18.0. The plugin typescript is recommended to remove, also because it's always in graphql-let/__generated__/__types__ now.

  schema: '**/*.graphqls'
- # "schemaEntrypoint" became obsolete
- schemaEntrypoint: lib/type-defs.graphqls
  documents: '**/*.graphql'
  plugins:
-   # "typescript" is not recommended
-   - typescript
    - typescript-operations
    - typescript-react-apollo
- cacheDir: __generated__
+ # ".cache" is now recommended to distinguish from "graphql-let/__generated__"
+ cacheDir: .cache

Please note that files in cacheDir are only intermediates. Exclude them from your TypeScript source.

  // tsconfig.json
  {
+   "excludes": [".cache"]
  }

Also, you're still able to have the plugin typescript in your config to keep importing types from the per-document output (*.graphql.d.ts). If so, you can skip step 3.

3. Change where you import types from

Again, your schema types are extracted and shared as graphql-let/__generated__/__types__. Please replace import parts of your source.

- import { User, ViewerDocument } from './viewer.graphql'
+ import { User } from 'graphql-let/__generated__/__types__'
+ import { ViewerDocument } from './viewer.graphql'

Optionally, you may want to have a path alias to it in your tsconfig.json for convenience.

  {
    "compilerOptions": {
      "noEmit": true,
      "esModuleInterop": true,
+     "baseUrl": ".",
+     "paths": {
+       "@graphql-types@": ["node_modules/@types/graphql-let/__generated__/__types__"]
+     }
    }
  }
import { User } from '@graphql-types@'

For Resolver Types users

Resolver Types also go in graphql-let/__generated__/__types__.

- import { Resolvers } from "./${config.schemaEntrypoint}";
+ import { Resolvers } from "graphql-let/__generated__/__types__";