Skip to content

Releases: eddeee888/graphql-code-generator-plugins

@eddeee888/gcg-typescript-resolver-files@0.7.4

11 Apr 10:16
b5d6e7b
Compare
Choose a tag to compare

Patch Changes

  • e909a17: fix path to output resolver files in main resolver files for nested schema files
  • 067bd7e: Add params to generated resolvers
  • 47c8fa6: Update package.json with missing deps
  • 891f718: fix path to output resolver files so they are always generated near to schema.graphql
  • b226761: Implement recursively pick interface extensions
  • Updated dependencies [47c8fa6]
    • @eddeee888/gcg-server-config@0.1.1

@eddeee888/gcg-server-config@0.1.1

11 Apr 10:16
b5d6e7b
Compare
Choose a tag to compare

Patch Changes

  • 47c8fa6: Update package.json with missing deps

@eddeee888/gcg-typescript-resolver-files@0.7.3

14 Mar 07:19
451dbf7
Compare
Choose a tag to compare

Patch Changes

  • 9f3b82b: Federation support: Add __resolveReference to picked fields when extending object types

@eddeee888/gcg-typescript-resolver-files@0.7.2

15 Dec 10:15
513e3e1
Compare
Choose a tag to compare

Patch Changes

  • 8ed14fc: Fix issue where dashes were not handled correctly when using extended object pattern across multiple schemas
  • 7567190: Declare tslib as a dependency

@eddeee888/gcg-typescript-resolver-files@0.7.1

20 Sep 01:55
beaf4d0
Compare
Choose a tag to compare

Patch Changes

  • 73d9936: Relax presetConfig.typesPluginsConfig.namingConvention enforcement. Warn if used.

    In v0.7.0, we've made presetConfig.typesPluginsConfig.namingConvention to throw if used. In this release, we've relaxed it because certain options may still work e.g. upperCaseFirst . If namingConvention is used, we warn instead.

    Currently, the preset naively uses the schema type spelling/casing as the generated type. Therefore, it's important to have namingConvention option as keep. In the future, we can revisit to make sure generated resolvers have the same namingConvention support as the generated type file.

@eddeee888/gcg-typescript-resolver-files@0.7.0

11 Sep 12:53
cbb2601
Compare
Choose a tag to compare

Minor Changes

  • ab6a9e7: Support extending non-root object types

    For example, given this schema:

    # user/schema.graphql
    type User {
      id: ID!
    }
    
    #  car/schema.graphql
    extend type User {
      cars: [Car!]!
    }
    
    # house/schema.graphql
    extend type User {
      housesOwned: [House!]!
      housesSold: [House!]!
    }

    It'd generate these files:

    // user/resolvers/User.ts
    export const User: Pick<UserResolvers, 'id'> = {
      // ...
    };
    
    // car/resolvers/User.ts
    export const User: Pick<UserResolvers, 'cars'> = {
      // ...
    };
    
    // house/resolvers/User.ts
    export const User: Pick<UserResolvers, 'housesOwned' | 'housesSold'> = {
      // ...
    };

    And the main resolver file:

    // resolvers.generated.ts
    import { User as user_User } from './user/resolvers/User';
    import { User as car_User } from './car/resolvers/User';
    import { User as house_User } from './house/resolvers/User';
    
    export const resolvers: Resolvers = {
      User: {
        ...user_User,
        ...car_User,
        ...house_User,
      },
    };
  • d5d9577: Drop support for typesPluginsConfig.namingConvention - this is now always keep

    In the preset, we made the assumption that the types used in resolver files are in the same format as the schema. So we keep the naming convention.

    Some types in types.generated.ts are affected. However, they are not currently used in any of the resolver files. So, if consumers have leaned into the recommended default config and generated resolver files (which is the intention of the preset), then there should be no issue upgrading.

  • 5497e8f: Add experimental support for add plugin.

    Consumers can use the preset's add option to do the equivalent of the add plugin to target the generated resolvers type file (default types.generated.ts).

    Example:

    // codegen.ts
    {
      generates: {
        'src/schema': defineConfig({
          add: {
            './types.generated.ts': { content: '/* eslint-disable */' },
          },
        })
      }
    }

Patch Changes

  • Updated dependencies [ccdc5e2]
    • @eddeee888/gcg-server-config@0.1.0

@eddeee888/gcg-server-config@0.1.0

11 Sep 12:53
cbb2601
Compare
Choose a tag to compare

Minor Changes

  • ccdc5e2: Add recommended default maybeValue option: T | null | undefined

@eddeee888/gcg-typescript-resolver-files@0.6.0

14 Aug 10:03
4f364ab
Compare
Choose a tag to compare

Minor Changes

  • d0e17ad: Add resolverGeneration option

    disabled or recommended or all (Default: recommended)

    Decides which resolvers to generate:

    • disabled: generates no resolvers. Use this if you want to use your own structures. Note: if custom scalars are detected and used, resolver main files are still generated.
    • recommended: generates the minimal amount of resolvers. Use this if you want a managed experience.
      • no union/interface resolvers are generated because we rely on certain settings in typescript-resolvers that make these not required.
    • all: generates all resolvers. Use this if you want all resolvers to be generated and use the ones you need.
  • 1586d73: Add missing Interface file generation

Patch Changes

  • c3ee642: Fix emitLegacyCommonJSImports issues

    • Fix issue where warning always logged if presetConfig.emitLegacyCommonJSImports is used
    • Throw error when presetConfig.typesPluginsConfig.emitLegacyCommonJSImports is used
    • (Internal) Replace automatic file detection in printImportLine with 3 options: file, module and preserve:
      • This is to fix rare cases where absolute alias path is used in externalResolvers option e.g. src/module/file was missing .js because it was being detected as a module. externalResolvers is set by the user and also used internally for scalar types, so we can use preserve instead to keep the module value as-is.
      • Options:
        • file: import is a file. For ESM, .js extension is added. For CJS, no extension is added.
        • module: import is a module from node_modules or aliased e.g. graphql-scalars or @org/your-module. No extension is added.
        • preserve: preserve what the config declares. This is only used when taking user's config or preset-controlled config e.g. externalExternals because the import could be either file or module
  • 191705f: Add schema option to defineConfig

  • 49ba468: Added support for the case where the Type mapper is a class

  • c968c2c: Fix: defineConfig's type no longer allows typesPluginsConfig.scalars or typesPluginsConfig.emitLegacyCommonJSImports

  • 2205e3f: Update default custom GraphQLScalar template to guide users better

  • Updated dependencies [5e58a08]

    • @eddeee888/gcg-server-config@0.0.1

@eddeee888/gcg-server-config@0.0.1

14 Aug 10:03
4f364ab
Compare
Choose a tag to compare

Patch Changes

  • 5e58a08: Add recommended config for GraphQL servers

@eddeee888/gcg-typescript-resolver-files@0.5.0

24 May 11:16
775267e
Compare
Choose a tag to compare

Minor Changes

  • f7831c1: Use resolversNonOptionalTypename instead of nonOptionalTypename

    This makes using abstract types simpler because we do not return __typename for all types, only for union members and interface implementing types.

  • f7831c1: Add scalarsOverrides config option

    Record<string, { resolver?: string; type?: string | { input: string; output: string } }> (Default: {})

    Overrides scalars' resolver implementation, type or both.

    Example:

    // codegen.ts
    {
      generates: {
        'src/schema': defineConfig({
          scalarsOverrides: {
            DateTime: {
              resolver: './localDateTimeResolver#Resolver',
            }
            Currency: {
              type: 'unknown'
            },
            BigInt: {
              resolver: '@other/scalars#BigIntResolver',
              type: 'bigint'
            }
          }
        })
      }
    }

    BREAKING CHANGE: typesPluginsConfig.scalars can no longer be used. Please use scalarOverrides instead.

  • f7831c1: Use optionalResolveType=true because resolversNonOptionalTypename works

  • f7831c1: Add scalarsModule config option

    string or false (Default: graphql-scalars)

    Where Scalar implementation and codegen types come from. Use false to implement your own Scalars.

    If using an module that is not graphql-scalars, the module must export resolver implementation and codegen type the same way graphql-scalars does e.g.

    {
      resolvers: {
        DateTime: DateTimeResolver,
      },
      DateTimeResolver: {
        // ... resolver implementation
        extensions: {
          codegenScalarType: 'Date | string',
        },
      }
    }

Patch Changes

  • f7831c1: Allows overriding native scalar types' type (Equivalent of typescript plugin's scalars option)
  • f7831c1: Correctly implement ID Scalar's input/output type: input is string and output is string | number

By default, ID scalar types are targeted at client types. Example generated type:

type Scalars = {
  ID: { 
    input: string | number; 
    output: string 
  }
}

Server preset manages the default ID scalar to be correct for server types. Example generated type for the server:

type Scalars = {
  ID: { 
    input: string; 
    output: string | number;
  }
}