Skip to content

Releases: dotansimha/graphql-code-generator

February 06, 2024

06 Feb 14:11
ebd0817
Compare
Choose a tag to compare

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

Patch Changes

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

Patch Changes

  • Updated dependencies [7718a8113]:
    • @graphql-codegen/visitor-plugin-common@4.1.1

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

Patch Changes

  • Updated dependencies [7718a8113]:
    • @graphql-codegen/visitor-plugin-common@4.1.1

@graphql-codegen/typescript-operations@4.1.1

Patch Changes

  • Updated dependencies [7718a8113]:
    • @graphql-codegen/visitor-plugin-common@4.1.1
    • @graphql-codegen/typescript@4.0.3

@graphql-codegen/typescript-resolvers@4.0.3

Patch Changes

  • #9673 7718a8113 Thanks @maclockard! - Respect avoidOptionals when all arguments are optional

  • Updated dependencies [7718a8113]:

    • @graphql-codegen/visitor-plugin-common@4.1.1
    • @graphql-codegen/typescript@4.0.3

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

Patch Changes

  • Updated dependencies [7718a8113]:
    • @graphql-codegen/visitor-plugin-common@4.1.1

@graphql-codegen/typescript@4.0.3

Patch Changes

  • Updated dependencies [7718a8113]:
    • @graphql-codegen/visitor-plugin-common@4.1.1

@graphql-codegen/client-preset@4.2.1

Patch Changes

  • #9557 48ddaeae1 Thanks @konomae! - Add eslint-disable comment to fragment-masking.ts

  • Updated dependencies [7718a8113]:

    • @graphql-codegen/visitor-plugin-common@4.1.1
    • @graphql-codegen/gql-tag-operations@4.0.3
    • @graphql-codegen/typescript-operations@4.1.1
    • @graphql-codegen/typed-document-node@5.0.3
    • @graphql-codegen/typescript@4.0.3

@graphql-codegen/graphql-modules-preset@4.0.3

Patch Changes

  • Updated dependencies [7718a8113]:
    • @graphql-codegen/visitor-plugin-common@4.1.1

July 25, 2023

25 Jul 09:20
5829dd9
Compare
Choose a tag to compare

@graphql-codegen/cli@5.0.0

Major Changes

Patch Changes

@graphql-codegen/client-preset@4.1.0

Minor Changes

  • #9562 5beee9794 Thanks @n1ru4l! - Add the addTypenameSelectionDocumentTransform for automatically adding __typename selections to all objct type selection sets.

    This is useful for GraphQL Clients such as Apollo Client or urql that need typename information for their cache to function.

    Example Usage

    import { addTypenameSelectionDocumentTransform } from '@graphql-codegen/client-preset';
    import { CodegenConfig } from "@graphql-codegen/cli";
    
    const config: CodegenConfig = {
      schema: "YOUR_GRAPHQL_ENDPOINT",
      documents: ["./**/*.{ts,tsx}"],
      ignoreNoDocuments: true,
      generates: {
        "./gql/": {
          preset: "client",
          plugins: [],
          presetConfig: {
            persistedDocuments: true,
          },
          documentTransforms: [addTypenameSelectionDocumentTransform],
        },
      },
    };
    
    export default config;
    

Patch Changes

  • Updated dependencies [bb1e0e96e]:
    • @graphql-codegen/plugin-helpers@5.0.1

@graphql-codegen/plugin-helpers@5.0.1

Patch Changes

June 19, 2023

19 Jun 07:32
a509268
Compare
Choose a tag to compare

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

Patch Changes

  • #9497 2276708d0 Thanks @eddeee888! - Revert default ID scalar input type to string

    We changed the ID Scalar input type from string to string | number in the latest major version of typescript plugin. This causes issues for server plugins (e.g. typescript-resolvers) that depends on typescript plugin. This is because the scalar type needs to be manually inverted on setup which is confusing.

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

Patch Changes

  • Updated dependencies [2276708d0]:
    • @graphql-codegen/visitor-plugin-common@4.0.1

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

Patch Changes

  • Updated dependencies [2276708d0]:
    • @graphql-codegen/visitor-plugin-common@4.0.1

@graphql-codegen/typescript-operations@4.0.1

Patch Changes

  • #9497 2276708d0 Thanks @eddeee888! - Revert default ID scalar input type to string

    We changed the ID Scalar input type from string to string | number in the latest major version of typescript plugin. This causes issues for server plugins (e.g. typescript-resolvers) that depends on typescript plugin. This is because the scalar type needs to be manually inverted on setup which is confusing.

  • Updated dependencies [2276708d0]:

    • @graphql-codegen/visitor-plugin-common@4.0.1
    • @graphql-codegen/typescript@4.0.1

@graphql-codegen/typescript-resolvers@4.0.1

Patch Changes

  • #9497 2276708d0 Thanks @eddeee888! - Revert default ID scalar input type to string

    We changed the ID Scalar input type from string to string | number in the latest major version of typescript plugin. This causes issues for server plugins (e.g. typescript-resolvers) that depends on typescript plugin. This is because the scalar type needs to be manually inverted on setup which is confusing.

  • Updated dependencies [2276708d0]:

    • @graphql-codegen/visitor-plugin-common@4.0.1
    • @graphql-codegen/typescript@4.0.1

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

Patch Changes

  • Updated dependencies [2276708d0]:
    • @graphql-codegen/visitor-plugin-common@4.0.1

@graphql-codegen/typescript@4.0.1

Patch Changes

  • #9497 2276708d0 Thanks @eddeee888! - Revert default ID scalar input type to string

    We changed the ID Scalar input type from string to string | number in the latest major version of typescript plugin. This causes issues for server plugins (e.g. typescript-resolvers) that depends on typescript plugin. This is because the scalar type needs to be manually inverted on setup which is confusing.

  • Updated dependencies [2276708d0]:

    • @graphql-codegen/visitor-plugin-common@4.0.1

@graphql-codegen/client-preset@4.0.1

Patch Changes

  • #9497 2276708d0 Thanks @eddeee888! - Revert default ID scalar input type to string

    We changed the ID Scalar input type from string to string | number in the latest major version of typescript plugin. This causes issues for server plugins (e.g. typescript-resolvers) that depends on typescript plugin. This is because the scalar type needs to be manually inverted on setup which is confusing.

  • Updated dependencies [2276708d0]:

    • @graphql-codegen/visitor-plugin-common@4.0.1
    • @graphql-codegen/typescript-operations@4.0.1
    • @graphql-codegen/typescript@4.0.1
    • @graphql-codegen/gql-tag-operations@4.0.1
    • @graphql-codegen/typed-document-node@5.0.1

@graphql-codegen/graphql-modules-preset@4.0.1

Patch Changes

  • Updated dependencies [2276708d0]:
    • @graphql-codegen/visitor-plugin-common@4.0.1

June 01, 2023

01 Jun 14:56
8bdcc66
Compare
Choose a tag to compare

@graphql-codegen/cli@4.0.1

Patch Changes

May 24, 2023

24 May 08:16
5c7b3b3
Compare
Choose a tag to compare

@graphql-codegen/cli@4.0.0

Major Changes

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

Patch Changes

@graphql-codegen/core@4.0.0

Major Changes

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

Patch Changes

@graphql-codegen/add@5.0.0

Major Changes

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

Patch Changes

@graphql-codegen/fragment-matcher@5.0.0

Major Changes

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

Patch Changes

@graphql-codegen/introspection@4.0.0

Major Changes

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

Patch Changes

@graphql-codegen/schema-ast@4.0.0

Major Changes

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

Patch Changes

Read more

April 22, 2023

22 Apr 13:43
21050ae
Compare
Choose a tag to compare

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

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

Patch Changes

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

Patch Changes

  • Updated dependencies [386cf9044, 402cb8ac0]:
    • @graphql-codegen/visitor-plugin-common@3.1.1

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

Patch Changes

  • Updated dependencies [386cf9044, 402cb8ac0]:
    • @graphql-codegen/visitor-plugin-common@3.1.1

@graphql-codegen/typescript-operations@3.0.4

Patch Changes

  • Updated dependencies [386cf9044, 402cb8ac0]:
    • @graphql-codegen/visitor-plugin-common@3.1.1
    • @graphql-codegen/typescript@3.0.4

@graphql-codegen/typescript-resolvers@3.2.1

Patch Changes

  • #9231 402cb8ac0 Thanks @eddeee888! - Implement resolversNonOptionalTypename for mapper cases

  • Updated dependencies [386cf9044, 402cb8ac0]:

    • @graphql-codegen/visitor-plugin-common@3.1.1
    • @graphql-codegen/typescript@3.0.4

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

Patch Changes

  • Updated dependencies [386cf9044, 402cb8ac0]:
    • @graphql-codegen/visitor-plugin-common@3.1.1

@graphql-codegen/typescript@3.0.4

Patch Changes

  • Updated dependencies [386cf9044, 402cb8ac0]:
    • @graphql-codegen/visitor-plugin-common@3.1.1

@graphql-codegen/client-preset@3.0.1

Patch Changes

  • Updated dependencies [386cf9044, 402cb8ac0]:
    • @graphql-codegen/visitor-plugin-common@3.1.1
    • @graphql-codegen/gql-tag-operations@3.0.1
    • @graphql-codegen/typescript-operations@3.0.4
    • @graphql-codegen/typed-document-node@4.0.1
    • @graphql-codegen/typescript@3.0.4

@graphql-codegen/graphql-modules-preset@3.1.3

Patch Changes

  • Updated dependencies [386cf9044, 402cb8ac0]:
    • @graphql-codegen/visitor-plugin-common@3.1.1

April 04, 2023

04 Apr 02:50
6e3fd38
Compare
Choose a tag to compare

@graphql-codegen/cli@3.3.0

Minor Changes

  • #9151 b7dacb21f Thanks @eddeee888! - 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: {
              User: './user/schema.mappers#UserMapper',
              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

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

Minor Changes

  • #9146 9f4d9c5a4 Thanks @eddeee888! - [typescript-resolvers] Add resolversNonOptionalTypename config option.

    This is extending on ResolversUnionTypes implemented in #9069

    resolversNonOptionalTypename adds non-optional __typename to union members of ResolversUnionTypes, without affecting the union members' base intefaces.

    A common use case for non-optional __typename of union members is using it as the common field to work out the final schema type. This makes implementing the union's __resolveType very simple as we can use __typename to decide which union member the resolved object is. Without this, we have to check the existence of field/s on the incoming object which could be verbose.

    For example, consider this schema:

    type Query {
      book(id: ID!): BookPayload!
    }
    
    type Book {
      id: ID!
      isbn: String!
    }
    
    type BookResult {
      node: Book
    }
    
    type PayloadError {
      message: String!
    }
    
    union BookPayload = BookResult | PayloadError

    With optional __typename: We need to check existence of certain fields to resolve type in the union resolver:

    // Query/book.ts
    export const book = async () => {
      try {
        const book = await fetchBook();
        // 1. No `__typename` in resolver results...
        return {
          node: book,
        };
      } catch (e) {
        return {
          message: 'Failed to fetch book',
        };
      }
    };
    
    // BookPayload.ts
    export const BookPayload = {
      __resolveType: parent => {
        // 2. ... means more checks in `__resolveType`
        if ('message' in parent) {
          return 'PayloadError';
        }
        return 'BookResult';
      },
    };

    With non-optional __typename: Resolvers declare the type. This which gives us better TypeScript support in resolvers and simplify __resolveType implementation:

    // Query/book.ts
    export const book = async () => {
      try {
        const book = await fetchBook();
        // 1. `__typename` is declared in resolver results...
        return {
          __typename: 'BookResult', // 1a. this also types `node` for us 🎉
          node: book,
        };
      } catch (e) {
        return {
          __typename: 'PayloadError',
          message: 'Failed to fetch book',
        };
      }
    };
    
    // BookPayload.ts
    export const BookPayload = {
      __resolveType: parent => parent.__typename, // 2. ... means a very simple check in `__resolveType`
    };

    Using resolversNonOptionalTypename: add it into typescript-resolvers plugin config:

    // codegen.ts
    const config: CodegenConfig = {
      schema: 'src/schema/**/*.graphql',
      generates: {
        'src/schema/types.ts': {
          plugins: ['typescript', 'typescript-resolvers'],
          config: {
            resolversNonOptionalTypename: true, // Or `resolversNonOptionalTypename: { unionMember: true }`
          },
        },
      },
    };

Patch Changes

  • #9206 e56790104 Thanks @eddeee888! - Fix ResolversUnionTypes being used in ResolversParentTypes

    Previously, objects with mappable fields are converted to Omit format that references its own type group or ResolversTypes or ResolversParentTypes e.g.

    export type ResolversTypes = {
      Book: ResolverTypeWrapper<BookMapper>;
      BookPayload: ResolversTypes['BookResult'] | ResolversTypes['StandardError'];
      // Note: `result` on the next line references `ResolversTypes["Book"]`
      BookResult: ResolverTypeWrapper<Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }>;
      StandardError: ResolverTypeWrapper<StandardError>;
    };
    
    export type ResolversParentTypes = {
      Book: BookMapper;
      BookPayload: ResolversParentTypes['BookResult'] | ResolversParentTypes['StandardError'];
      // Note: `result` on the next line references `ResolversParentTypes["Book"]`
      BookResult: Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> };
      StandardError: StandardError;
    };

    In #9069, we extracted resolver union types to its own group:

    export type ResolversUnionTypes = {
      // Note: `result` on the next line references `ResolversTypes["Book"]` which is only correct for the `ResolversTypes` case
      BookPayload: (Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }) | StandardError;
    };
    
    export type ResolversTypes = {
      Book: ResolverTypeWrapper<BookMapper>;
      BookPayload: ResolverTypeWrapper<ResolversUnionTypes['BookPayload']>;
      BookResult: ResolverTypeWrapper<Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }>;
      StandardError: ResolverTypeWrapper<StandardError>;
    };
    
    export type ResolversParentTypes = {
      Book: BookMapper;
      BookPayload: ResolversUnionTypes['BookPayload'];
      BookResult: Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> };
      StandardError: StandardError;
    };

    This change creates an extra ResolversUnionParentTypes that is referenced by ResolversParentTypes to ensure backwards compatibility:

    export type ResolversUnionTypes = {
      BookPayload: (Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> }) | StandardError;
    };
    
    // ... and the reference is changed in ResolversParentTypes:
    export type ResolversParentTypes = {
      // ... other fields
      BookPayload: ResolversUnionParentTypes['BookPayload'];
    };
  • #9194 acb647e4e Thanks @dstaley! - Don't emit import statements for unused fragments

  • Updated dependencies [b7dacb21f, f104619ac]:

    • @graphql-codegen/plugin-helpers@4.2.0

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

Patch Changes

Read more

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