Skip to content

Releases: dotansimha/graphql-code-generator

March 07, 2023

07 Mar 11:40
d6c37db
Compare
Choose a tag to compare

@graphql-cli/codegen@3.0.4

Patch Changes

@graphql-codegen/cli@3.2.2

Patch Changes

@graphql-codegen/visitor-plugin-common@3.0.2

Patch Changes

@graphql-codegen/typescript-document-nodes@3.0.2

Patch Changes

@graphql-codegen/gql-tag-operations@2.0.2

Patch Changes

@graphql-codegen/typescript-operations@3.0.2

Patch Changes

  • Updated dependencies [ba0610bbd, 4b49f6fbe, b343626c9]:
    • @graphql-codegen/visitor-plugin-common@3.0.2
    • @graphql-codegen/typescript@3.0.2

@graphql-codegen/typescript-resolvers@3.1.1

Patch Changes

@graphql-codegen/typed-document-node@3.0.2

Patch Changes

@graphql-codegen/typescript@3.0.2

Patch Changes

@graphql-codegen/client-preset@2.1.1

Patch Changes

@graphql-codegen/graphql-modules-preset@3.1.1

Patch Changes

February 23, 2023

23 Feb 18:57
f1536d1
Compare
Choose a tag to compare

@graphql-cli/codegen@3.0.3

Patch Changes

@graphql-codegen/cli@3.2.1

Patch Changes

February 22, 2023

22 Feb 19:23
7b49e97
Compare
Choose a tag to compare

@graphql-cli/codegen@3.0.2

Patch Changes

@graphql-codegen/cli@3.2.0

Minor Changes

Patch Changes

February 21, 2023

21 Feb 16:12
a1edaee
Compare
Choose a tag to compare

@graphql-codegen/cli@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

@graphql-codegen/core@3.1.0

Minor Changes

  • #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

@graphql-codegen/typescript-resolvers@3.1.0

Minor Changes

Patch Changes

Read more

February 03, 2023

03 Feb 10:21
c606aa8
Compare
Choose a tag to compare

@graphql-cli/codegen@3.0.0

Major Changes

Patch Changes

@graphql-codegen/cli@3.0.0

Major Changes

Patch Changes

@graphql-codegen/core@3.0.0

Major Changes

Patch Changes

@graphql-codegen/add@4.0.0

Major Changes

Patch Changes

@graphql-codegen/fragment-matcher@4.0.0

Major Changes

Patch Changes

@graphql-codegen/introspection@3.0.0

Major Changes

Patch Changes

  • Updated dependencies [fc79b65d4, fd0b0c813]:
    • @graphql-codegen/visitor-plugin-common@3.0.0
    • @graphql-codegen/plugin-helpers@4.0.0

@graphql-codegen/schema-ast@3.0.0

Major Changes

Patch Changes

@graphql-codegen/time@4.0.0

Major Changes

Patch Changes

@graphql-codegen/visitor-plugin-common@3.0.0

Major Changes

Patch Changes

@graphql-codegen/typescript-document-nodes@3.0.0

Major Changes

Patch Changes

  • Updated dependencies [fc79b65d4, fd0b0c813]:
    • @graphql-codegen/visitor-plugin-common@3.0.0
    • @graphql-codegen/plugin-helpers@4.0.0

@graphql-codegen/gql-tag-operations@2.0.0

Major Changes

Patch Changes

  • Updated dependencies [fc79b65d4, fd0b0c813]:
    • @graphql-codegen/visitor-plugin-common@3.0.0
    • @graphql-codegen/plugin-helpers@4.0.0

@graphql-codegen/typescript-operations@3.0.0

Major Changes

Patch Changes

  • Updated dependencies [fc79b65d4, fd0b0c813]:
    • @graphql-codegen/visitor-plugin-common@3.0.0
    • @graphql-codegen/plugin-helpers@4.0.0
    • @graphql-codegen/typescript@3.0.0

@graphql-codegen/typescript-resolvers@3.0.0

Major Changes

Patch Changes

  • #8871 fc79b65d4 Thanks @B2o5T! - eslint fixes

  • Updated dependencies [fc79b65d4, fd0b0c813]:

    • @graphql-codegen/visitor-plugin-common@3.0.0
    • @graphql-codegen/plugin-helpers@4.0.0
    • @graphql-codegen/typescript@3.0.0

@graphql-codegen/typed-document-node@3.0.0

Major Changes

Read more

January 30, 2023

30 Jan 22:36
1c17d8f
Compare
Choose a tag to compare

@graphql-codegen/testing@1.18.3

Patch Changes

January 30, 2023

30 Jan 14:26
2a7e9ac
Compare
Choose a tag to compare

@graphql-cli/codegen@2.4.25

Patch Changes

@graphql-codegen/cli@2.16.5

Patch Changes

@graphql-codegen/visitor-plugin-common@2.13.8

Patch Changes

  • #8816 a98198524 Thanks @charle692! - Fix issue where visitor-plugin-common emitted ESM imports for Operations when emitLegacyCommonJSImports is true

@graphql-codegen/typescript-document-nodes@2.3.13

Patch Changes

  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8

@graphql-codegen/gql-tag-operations@1.6.2

Patch Changes

  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8

@graphql-codegen/typescript-operations@2.5.13

Patch Changes

  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8
    • @graphql-codegen/typescript@2.8.8

@graphql-codegen/typescript-resolvers@2.7.13

Patch Changes

  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8
    • @graphql-codegen/typescript@2.8.8

@graphql-codegen/typed-document-node@2.3.13

Patch Changes

  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8

@graphql-codegen/typescript@2.8.8

Patch Changes

  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8

@graphql-codegen/client-preset@1.3.0

Minor Changes

  • #8757 4f290aa72 Thanks @n1ru4l! - Add support for persisted documents.

    You can now generate and embed a persisted documents hash for the executable documents.

    /** codegen.ts */
    import { CodegenConfig } from '@graphql-codegen/cli';
    
    const config: CodegenConfig = {
      schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
      documents: ['src/**/*.tsx'],
      ignoreNoDocuments: true, // for better experience with the watcher
      generates: {
        './src/gql/': {
          preset: 'client',
          plugins: [],
          presetConfig: {
            persistedDocuments: true,
          },
        },
      },
    };
    
    export default config;

    This will generate ./src/gql/persisted-documents.json (dictionary of hashes with their operation string).

    In addition to that each generated document node will have a __meta__.hash property.

    import { gql } from './gql.js';
    
    const allFilmsWithVariablesQueryDocument = graphql(/* GraphQL */ `
      query allFilmsWithVariablesQuery($first: Int!) {
        allFilms(first: $first) {
          edges {
            node {
              ...FilmItem
            }
          }
        }
      }
    `);
    
    console.log((allFilmsWithVariablesQueryDocument as any)['__meta__']['hash']);
  • #8757 4f290aa72 Thanks @n1ru4l! - Add support for embedding metadata in the document AST.

    It is now possible to embed metadata (e.g. for your GraphQL client within the emitted code).

    /** codegen.ts */
    import { CodegenConfig } from '@graphql-codegen/cli';
    
    const config: CodegenConfig = {
      schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
      documents: ['src/**/*.tsx'],
      ignoreNoDocuments: true, // for better experience with the watcher
      generates: {
        './src/gql/': {
          preset: 'client',
          plugins: [],
          presetConfig: {
            onExecutableDocumentNode(documentNode) {
              return {
                operation: documentNode.definitions[0].operation,
                name: documentNode.definitions[0].name.value,
              };
            },
          },
        },
      },
    };
    
    export default config;

    You can then access the metadata via the __meta__ property on the document node.

    import { gql } from './gql.js';
    
    const allFilmsWithVariablesQueryDocument = graphql(/* GraphQL */ `
      query allFilmsWithVariablesQuery($first: Int!) {
        allFilms(first: $first) {
          edges {
            node {
              ...FilmItem
            }
          }
        }
      }
    `);
    
    console.log((allFilmsWithVariablesQueryDocument as any)['__meta__']);

Patch Changes

  • #8757 4f290aa72 Thanks @n1ru4l! - dependencies updates:
  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8
    • @graphql-codegen/gql-tag-operations@1.6.2
    • @graphql-codegen/typescript-operations@2.5.13
    • @graphql-codegen/typed-document-node@2.3.13
    • @graphql-codegen/typescript@2.8.8

@graphql-codegen/graphql-modules-preset@2.5.12

Patch Changes

  • Updated dependencies [a98198524]:
    • @graphql-codegen/visitor-plugin-common@2.13.8

January 10, 2023

10 Jan 19:32
a1eb167
Compare
Choose a tag to compare

@graphql-cli/codegen@2.4.24

Patch Changes

@graphql-codegen/cli@2.16.4

Patch Changes

@graphql-codegen/gql-tag-operations@1.6.1

Patch Changes

  • #8796 902451601 Thanks @shmax! - remove extra asterisk and add missing semicolon in generated output

@graphql-codegen/client-preset@1.2.6

Patch Changes

  • #8796 902451601 Thanks @shmax! - remove extra asterisk and add missing semicolon in generated output

  • Updated dependencies [902451601]:

    • @graphql-codegen/gql-tag-operations@1.6.1

@graphql-codegen/gql-tag-operations-preset@1.7.4

Patch Changes

  • #8796 902451601 Thanks @shmax! - remove extra asterisk and add missing semicolon in generated output

  • Updated dependencies [902451601]:

    • @graphql-codegen/gql-tag-operations@1.6.1

January 04, 2023

04 Jan 16:40
e50e0b3
Compare
Choose a tag to compare

@graphql-cli/codegen@2.4.23

Patch Changes

  • Updated dependencies [ad5d83313]:
    • @graphql-codegen/cli@2.16.3

@graphql-codegen/cli@2.16.3

Patch Changes

@graphql-codegen/visitor-plugin-common@2.13.7

Patch Changes

@graphql-codegen/typescript-document-nodes@2.3.12

Patch Changes

  • Updated dependencies [eb454d06c]:
    • @graphql-codegen/visitor-plugin-common@2.13.7

@graphql-codegen/gql-tag-operations@1.6.0

Minor Changes

Patch Changes

  • Updated dependencies [eb454d06c]:
    • @graphql-codegen/visitor-plugin-common@2.13.7

@graphql-codegen/typescript-operations@2.5.12

Patch Changes

  • Updated dependencies [eb454d06c]:
    • @graphql-codegen/visitor-plugin-common@2.13.7
    • @graphql-codegen/typescript@2.8.7

@graphql-codegen/typescript-resolvers@2.7.12

Patch Changes

  • Updated dependencies [eb454d06c]:
    • @graphql-codegen/visitor-plugin-common@2.13.7
    • @graphql-codegen/typescript@2.8.7

@graphql-codegen/typed-document-node@2.3.12

Patch Changes

  • Updated dependencies [eb454d06c]:
    • @graphql-codegen/visitor-plugin-common@2.13.7

@graphql-codegen/typescript@2.8.7

Patch Changes

  • Updated dependencies [eb454d06c]:
    • @graphql-codegen/visitor-plugin-common@2.13.7

@graphql-codegen/client-preset@1.2.5

Patch Changes

  • Updated dependencies [eb454d06c, 2a33fc774]:
    • @graphql-codegen/visitor-plugin-common@2.13.7
    • @graphql-codegen/gql-tag-operations@1.6.0
    • @graphql-codegen/typescript-operations@2.5.12
    • @graphql-codegen/typed-document-node@2.3.12
    • @graphql-codegen/typescript@2.8.7

@graphql-codegen/graphql-modules-preset@2.5.11

Patch Changes

  • Updated dependencies [eb454d06c]:
    • @graphql-codegen/visitor-plugin-common@2.13.7

December 27, 2022

27 Dec 20:27
8248c50
Compare
Choose a tag to compare

@graphql-cli/codegen@2.4.22

Patch Changes

@graphql-codegen/cli@2.16.2

Patch Changes

@graphql-codegen/schema-ast@2.6.1

Patch Changes

@graphql-codegen/visitor-plugin-common@2.13.6

Patch Changes

@graphql-codegen/typescript-document-nodes@2.3.11

Patch Changes

  • Updated dependencies [ed87c782b, ed87c782b, 6c6b6f2df]:
    • @graphql-codegen/plugin-helpers@3.1.2
    • @graphql-codegen/visitor-plugin-common@2.13.6

@graphql-codegen/gql-tag-operations@1.5.12

Patch Changes

@graphql-codegen/typescript-operations@2.5.11

Patch Changes

  • Updated dependencies [ed87c782b, ed87c782b, 6c6b6f2df]:
    • @graphql-codegen/plugin-helpers@3.1.2
    • @graphql-codegen/visitor-plugin-common@2.13.6
    • @graphql-codegen/typescript@2.8.6

@graphql-codegen/typescript-resolvers@2.7.11

Patch Changes

@graphql-codegen/typed-document-node@2.3.11

Patch Changes

  • Updated dependencies [ed87c782b, ed87c782b, 6c6b6f2df]:
    • @graphql-codegen/plugin-helpers@3.1.2
    • @graphql-codegen/visitor-plugin-common@2.13.6

@graphql-codegen/typescript@2.8.6

Patch Changes

  • Updated dependencies [ed87c782b, ed87c782b, ed87c782b, 6c6b6f2df]:
    • @graphql-codegen/plugin-helpers@3.1.2
    • @graphql-codegen/schema-ast@2.6.1
    • @graphql-codegen/visitor-plugin-common@2.13.6

@graphql-codegen/client-preset@1.2.4

Patch Changes

Read more