Skip to content

Latest commit

 

History

History
1086 lines (663 loc) · 53.2 KB

File metadata and controls

1086 lines (663 loc) · 53.2 KB

@graphql-codegen/cli

5.0.1

Patch Changes

5.0.0

Major Changes

Patch Changes

4.0.1

Patch Changes

4.0.0

Major Changes

  • bb66c2a31 Thanks @n1ru4l! - Require Node.js >= 16. Drop support for Node.js 14

Patch Changes

3.3.1

Patch Changes

  • #9267 183749346 Thanks @milesrichardson! - Fix watch mode to listen to longest common directory prefix of relevant files, rather than only files below the current working directory (fixes #9266).

  • #9280 ca1d72c40 Thanks @saihaj! - fix the default output directory for init command

3.3.0

Minor Changes

  • #9151 b7dacb21f Thanks @'./user/schema.mappers#UserMapper',! - Add watchPattern config option for generates sections.

    By default, watch mode automatically watches all GraphQL schema and document files. This means when a change is detected, Codegen CLI is run.

    A user may want to run Codegen CLI when non-schema and non-document files are changed. Each generates section now has a watchPattern option to allow more file patterns to be added to the list of patterns to watch.

    In the example below, mappers are exported from schema.mappers.ts files. We want to re-run Codegen if the content of *.mappers.ts files change because they change the generated types file. To solve this, we can add mapper file patterns to watch using the glob pattern used for schema and document files.

    // codegen.ts
    const config: CodegenConfig = {
      schema: 'src/schema/**/*.graphql',
      generates: {
        'src/schema/types.ts': {
          plugins: ['typescript', 'typescript-resolvers'],
          config: {
            mappers: {
    
              Book: './book/schema.mappers#BookMapper',
            },
          }
          watchPattern: 'src/schema/**/*.mappers.ts', // Watches mapper files in `watch` mode. Use an array for multiple patterns e.g. `['src/*.pattern1.ts','src/*.pattern2.ts']`
        },
      },
    };

    Then, run Codegen CLI in watch mode:

    yarn graphql-codegen --watch

    Now, updating *.mappers.ts files re-runs Codegen! 🎉

    Note: watchPattern is only used in watch mode i.e. running CLI with --watch flag.

Patch Changes

3.2.2

Patch Changes

3.2.1

Patch Changes

3.2.0

Minor Changes

Patch Changes

3.1.0

Minor Changes

  • #8893 a118c307a Thanks @n1ru4l! - It is no longer mandatory to declare an empty plugins array when using a preset

  • #8723 a3309e63e Thanks @kazekyo! - Introduce a new feature called DocumentTransform.

    DocumentTransform is a functionality that allows you to modify documents before they are processed by plugins. You can use functions passed to the documentTransforms option to make changes to GraphQL documents.

    To use this feature, you can write documentTransforms as follows:

    import type { CodegenConfig } from '@graphql-codegen/cli';
    
    const config: CodegenConfig = {
      schema: 'https://localhost:4000/graphql',
      documents: ['src/**/*.tsx'],
      generates: {
        './src/gql/': {
          preset: 'client',
          documentTransforms: [
            {
              transform: ({ documents }) => {
                // Make some changes to the documents
                return documents;
              },
            },
          ],
        },
      },
    };
    export default config;

    For instance, to remove a @localOnlyDirective directive from documents, you can write the following code:

    import type { CodegenConfig } from '@graphql-codegen/cli';
    import { visit } from 'graphql';
    
    const config: CodegenConfig = {
      schema: 'https://localhost:4000/graphql',
      documents: ['src/**/*.tsx'],
      generates: {
        './src/gql/': {
          preset: 'client',
          documentTransforms: [
            {
              transform: ({ documents }) => {
                return documents.map(documentFile => {
                  documentFile.document = visit(documentFile.document, {
                    Directive: {
                      leave(node) {
                        if (node.name.value === 'localOnlyDirective') return null;
                      },
                    },
                  });
                  return documentFile;
                });
              },
            },
          ],
        },
      },
    };
    export default config;

    DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to documentTransforms.

    Let's create the document transform as a file:

    module.exports = {
      transform: ({ documents }) => {
        // Make some changes to the documents
        return documents;
      },
    };

    Then, you can specify the file name as follows:

    import type { CodegenConfig } from '@graphql-codegen/cli';
    
    const config: CodegenConfig = {
      schema: 'https://localhost:4000/graphql',
      documents: ['src/**/*.tsx'],
      generates: {
        './src/gql/': {
          preset: 'client',
          documentTransforms: ['./my-document-transform.js'],
        },
      },
    };
    export default config;

Patch Changes

3.0.0

Major Changes

Patch Changes

2.16.5

Patch Changes

2.16.4

Patch Changes

2.16.3

Patch Changes

2.16.2

Patch Changes

2.16.1

Patch Changes

  • Updated dependencies [307a5d350, 46f75304a]:
    • @graphql-codegen/plugin-helpers@3.1.1
    • @graphql-codegen/core@2.6.8

2.16.0

Minor Changes

  • #8662 c0183810f Thanks @jantimon! - the life cycle hook beforeOneFileWrite is now able to modify the generated content

Patch Changes

  • Updated dependencies [c0183810f]:
    • @graphql-codegen/plugin-helpers@3.1.0

2.15.1

Patch Changes

2.15.0

Minor Changes

2.14.1

Patch Changes

2.14.0

Minor Changes

Patch Changes

2.13.12

Patch Changes

2.13.11

Patch Changes

2.13.10

Patch Changes

2.13.9

Patch Changes

  • #8525 63dc8f205 Thanks @charlypoly! - remove DetailledError, not supported by Listr renderer

  • Updated dependencies [63dc8f205]:

    • @graphql-codegen/core@2.6.3
    • @graphql-codegen/plugin-helpers@2.7.2

2.13.8

Patch Changes

2.13.7

Patch Changes

2.13.6

Patch Changes

2.13.5

Patch Changes

2.13.4

Patch Changes

2.13.3

Patch Changes

2.13.2

Patch Changes

2.13.1

Patch Changes

2.13.0

Minor Changes

  • #8302 876844e76 Thanks @charlypoly! - @graphql-codegen/gql-tag-operations and @graphql-codegen/gql-tag-operations-preset

    Introduce a gqlTagName configuration option


    @graphql-codegen/client-preset

    New preset for GraphQL Code Generator v3, more information on the RFC: #8296


    @graphql-codegen/cli

    Update init wizard with 3.0 recommendations (codegen.ts, client preset)

Patch Changes

2.12.2

Patch Changes

2.12.1

Patch Changes

2.12.0

Minor Changes

  • #8301 2ed21a471 Thanks @charlypoly! - Introduces support for TypeScript config file and a new preset lifecycle (required for client-preset)

Patch Changes

2.11.8

Patch Changes

2.11.7

Patch Changes

2.11.6

Patch Changes

  • Updated dependencies [6c7d3e54b]:
    • @graphql-codegen/core@2.6.2

2.11.5

Patch Changes

2.11.4

Patch Changes

  • #8189 b408f8238 Thanks @n1ru4l! - Fix CommonJS TypeScript resolution with moduleResolution node16 or nodenext

  • Updated dependencies [b408f8238]:

    • @graphql-codegen/core@2.6.1
    • @graphql-codegen/plugin-helpers@2.6.2

2.11.3

Patch Changes

  • b75ca4b48: Prevent cli from early returning when run init command.

2.11.2

Patch Changes

  • 8cd1526c4: chore(deps): update @whatwg-node/fetch to fix vulnerability

2.11.1

Patch Changes

  • 20bf4b225: support for path containing "&" characters

2.11.0

Minor Changes

  • fd6be805b: feat(cli): add a dry-run mode with --check cli flag

Patch Changes

  • 6a2e328e6: feat(cli): --verbose and --debug flags
  • Updated dependencies [6a2e328e6]
    • @graphql-codegen/plugin-helpers@2.6.1

2.10.0

Minor Changes

  • 273ad602f: Replace cross-undici-fetch with @whatwg-node/fetch to fix security vulnerability from undici

Patch Changes

  • cc18923d3: feat(hooks): forward hooks logs to debug logs

2.9.1

Patch Changes

  • e2cfc5c36: fix(cli): prevent duplicated error messages on fail (without watcher)

2.9.0

Minor Changes

  • 2cbcbb371: Add new flag to emit legacy common js imports. Default it will be true this way it ensure that generated code works with non-compliant bundlers.

    You can use the option in your config:

    schema: 'schema.graphql'
     documents:
       - 'src/**/*.graphql'
     emitLegacyCommonJSImports: true

    Alternative you can use the CLI to set this option:

    $ codegen --config-file=config.yml --emit-legacy-common-js-imports

Patch Changes

  • 32c1560f1: getPluginByName fails unexpectedly when plugin is not prefixed with @graphq-codegen in ESM context

    MODULE_NOT_FOUND is the error code you receive in a CommonJS context when you require() a module and it does not exist. ERR_MODULE_NOT_FOUND is the error code you receive in an ESM context when you import or import() ad module that does not exist.

  • Updated dependencies [2cbcbb371]

    • @graphql-codegen/plugin-helpers@2.6.0

2.8.1

Patch Changes

  • 147e801bf: Add tslib as a dependency. See #8075

2.8.0

Minor Changes

  • d84afec09: Add bin CLI command for running graphql-code-generator in ESM mode. You can now use graphql-codegen-esm instead of graphql-codegen.

    GraphQL Code Generator will continue supporting both ESM and CommonJS in parallel.

  • d84afec09: Support TypeScript ESM modules ("module": "node16" and "moduleResolution": "node16").

    More information on the TypeScript Release Notes.

  • 8e44df58b: Add new config option to not exit with non-zero exit code when there are no documents.

    You can use this option in your config:

    schema: 'schema.graphql'
    documents:
      - 'src/**/*.graphql'
    ignoreNoDocuments: true

    Alternative you can use the CLI to set this option:

    $ codegen --config-file=config.yml --ignore-no-documents

Patch Changes

  • e7870ac28: Fix security vulnerability by removing latest-version dependency.

  • dce40edeb: Allow to disable watch mode from CLI to overwrite the config. Now you can do:

    $ graphql-codegen --watch=false
  • 2e86ecb65: ### Summary

    • Migrate to listr2
    • Remove custom renderer for listr
    • Remove unused dependencies

    Why

    listr is not actively maintained and we have to maintain our custom renderer for it to display errors. Migrating to listr2 it just works out of the almost similar to how it was working in past and is a actively maintained.

    Dev notes

    Big change for us is how errors were collected. In listr errors were thrown and were caught in the end function of our custom listr Renderer but with listr2 we don't really get Error in end function always so instead we use the context to collect errors from all the tasks and then show them after all the tasks are finished.

  • Updated dependencies [d84afec09]

  • Updated dependencies [a4fe5006b]

  • Updated dependencies [8e44df58b]

    • @graphql-codegen/core@2.6.0
    • @graphql-codegen/plugin-helpers@2.5.0

2.7.0

Minor Changes

  • e050230c0: Remove unnecessary browser check

Patch Changes

  • dfd9f07dc: Fix/multi project
  • 2fb1d8b87: Remove unused tryToBuildSchema function
  • 4dce44263: Bumps @graphql-tools/url-loader to the latest cross-undici-fetch version that has pinned undici to ~5.5.0 in order to fix a bug/breaking-change introduced with undici@5.6.0 that causes a GET/HEAD requests cannot have 'body' error. See ardatan/graphql-tools#4559 (comment) for more details.

2.6.4

Patch Changes

  • 92f714278: Revert "Upgrade latest version"

2.6.3

Patch Changes

  • c1fe7758a: Remove unused deps
  • 52b41e90e: bump latest-version to patch vuln

2.6.2

Patch Changes

  • 1e3d37a34: resolve local presets

2.6.1

Patch Changes

  • cb9adeb96: Cache validation of documents
  • Updated dependencies [cb9adeb96]
    • @graphql-codegen/core@2.5.1
    • @graphql-codegen/plugin-helpers@2.4.1

2.6.0

Minor Changes

  • 35566a02c: Use os.cpus to calculate concurrency limit
  • acc62e548: fix(deps): remove unnecessary dotenv main dependency
  • 35566a02c: Async File System

2.5.0

Minor Changes

  • 754a33715: Performance Profiler --profile

Patch Changes

  • f13d3554e: #5064 Display detailed errors from CLI
  • be7cb3a82: Performance work: resolvers plugins, documents loading
  • Updated dependencies [754a33715]
    • @graphql-codegen/core@2.5.0
    • @graphql-codegen/plugin-helpers@2.4.0

2.4.0

Minor Changes

  • 4c42e2a71: Performance optimizations in schema and documents loading (shared promises)

2.3.1

Patch Changes

  • 6002feb3d: Fix exports in package.json files for react-native projects
  • Updated dependencies [8643b3bf3]
  • Updated dependencies [b61dc57cf]
  • Updated dependencies [6002feb3d]
    • @graphql-codegen/core@2.4.0
    • @graphql-codegen/plugin-helpers@2.3.2

2.3.0

Minor Changes

  • 50c1d3247: feat(cli): export loadCodegenConfig to load codegen configuration files

Patch Changes

  • 04e2d833b: export generateSearchPlaces

2.2.2

Patch Changes

  • Updated dependencies [97ddb487a]
    • @graphql-codegen/core@2.3.0
    • @graphql-codegen/plugin-helpers@2.3.0

2.2.1

Patch Changes

  • Updated dependencies [7c60e5acc]
    • @graphql-codegen/core@2.2.0
    • @graphql-codegen/plugin-helpers@2.2.0

2.2.0

Minor Changes

  • 3e38de399: enhance: sort the schema before processing to have more consistent results. You can disable it with sort: false.

Patch Changes

  • 3e38de399: fix: handle convertExtensions properly with schema definitions

2.1.1

Patch Changes

  • d3c556f8e: fix: do not alter the indentation of documents

2.1.0

Minor Changes

  • 39773f59b: enhance(plugins): use getDocumentNodeFromSchema and other utilities from @graphql-tools/utils
  • 440172cfe: support ESM

Patch Changes

  • 24185985a: bump graphql-tools package versions
  • 72044c1bd: fix: do not alter the indentation of documents loaded via graphql-config
  • Updated dependencies [24185985a]
  • Updated dependencies [39773f59b]
  • Updated dependencies [440172cfe]
    • @graphql-codegen/core@2.1.0
    • @graphql-codegen/plugin-helpers@2.1.0

2.0.1

Patch Changes

  • edd029e87: fix(graphql-modules-preset): do not parse SDL and use extendedSources that have parsed document already

2.0.0

Major Changes

  • b0cb13df4: Update to latest graphql-tools and graphql-config version.

    ‼️ ‼️ ‼️ Please note ‼️ ‼️ ‼️:

    This is a breaking change since Node 10 is no longer supported in graphql-tools, and also no longer supported for Codegen packages.

Patch Changes

  • Updated dependencies [b0cb13df4]
  • Updated dependencies [d80efdec4]
    • @graphql-codegen/core@2.0.0
    • @graphql-codegen/plugin-helpers@2.0.0

1.21.8

Patch Changes

  • e1643e6d4: Fix exception loader.loaderId is not a function caused by conflict with an internal dependency of Codegen.

1.21.7

Patch Changes

  • 470336a1: don't require plugins for for config if preset provides plugin. Instead the preset should throw if no plugins were provided.
  • Updated dependencies [470336a1]
    • @graphql-codegen/plugin-helpers@1.18.8

1.21.6

Patch Changes

  • 3b82d1bd: update chokidar

1.21.5

Patch Changes

  • dfd25caf: chore(deps): bump graphql-tools versions
  • Updated dependencies [dfd25caf]
    • @graphql-codegen/core@1.17.10
    • @graphql-codegen/plugin-helpers@1.18.7

1.21.4

Patch Changes

  • d9212aa0: fix(visitor-plugin-common): guard for a runtime type error
  • Updated dependencies [d9212aa0]
    • @graphql-codegen/plugin-helpers@1.18.5

1.21.3

Patch Changes

  • 23862e7e: fix(naming-convention): revert and pin change-case-all dependency for workaround #3256
  • Updated dependencies [23862e7e]
    • @graphql-codegen/plugin-helpers@1.18.4

1.21.2

Patch Changes

  • 29b75b1e: enhance(namingConvention): use change-case-all instead of individual packages for naming convention
  • Updated dependencies [29b75b1e]
    • @graphql-codegen/plugin-helpers@1.18.3

1.21.0

Minor Changes

  • dfef1c7c: feat(cli): pass parameters to loaders from plugin config

1.20.1

Patch Changes

  • f86365c2: Dependencies cleanup

1.20.0

Minor Changes

  • 0e9ddb5a: Add merge (<<) syntax for yaml configurations

Patch Changes

  • bff3fa88: CLI with watch option will reload using new config on change
  • 9ebf1877: Fix wrong MODULE_NOT_FOUND for missing dependencies
  • aa955f15: fix hooks as single function

1.19.4

Patch Changes

  • 920d8e95: Allow loading configuration from package.json file

1.19.3

Patch Changes

  • 1183d173: Bump all packages to resolve issues with shared dependencies
  • Updated dependencies [1183d173]
    • @graphql-codegen/core@1.17.9
    • @graphql-codegen/plugin-helpers@1.18.2

1.19.2

Patch Changes

  • faa13973: Fix issues with missing sources in loadSchema
  • faa13973: fix(cli): use default options of codegen for graphql-config's load methods

1.19.1

Patch Changes

  • 4ad0319a: Resolve modules passed through the -r flag relative to the cwd
  • 93e49f89: Correctly resolve relative to the cwd
  • Updated dependencies [eaf45d1f]
    • @graphql-codegen/plugin-helpers@1.18.1

1.19.0

Minor Changes

  • 857c603c: Adds the --errors-only flag to the cli to print errors only.

Patch Changes

  • Updated dependencies [857c603c]
    • @graphql-codegen/plugin-helpers@1.18.0

1.18.0

Minor Changes

  • ceb9fe0c: Changes watch mode to not use polling by default and adds configurable override

Patch Changes

  • 186962c9: Use fs.statSync when creating custom require instead of path.extname

1.17.10

Patch Changes

  • 2900ee29: Check the error code instead of the error message to determine if a package wasn't found

1.17.9

Patch Changes

  • e7d56e32: fix issues with init command and missing versions
  • 398b094b: Load user provided things relative to the config
  • Updated dependencies [da8bdd17]
    • @graphql-codegen/plugin-helpers@1.17.9

1.17.8

Patch Changes

  • 1d7c6432: Bump all packages to allow "^" in deps and fix compatibility issues
  • 1d7c6432: Bump versions of @graphql-tools/ packages to fix issues with loading schemas and SDL comments
  • Updated dependencies [1d7c6432]
  • Updated dependencies [1d7c6432]
  • Updated dependencies [ac067ea0]
    • @graphql-codegen/core@1.17.8
    • @graphql-codegen/plugin-helpers@1.17.8