github dotansimha/graphql-code-generator @graphql-codegen/typescript@2.2.0

latest releases: release-1730117942954, @graphql-codegen/visitor-plugin-common@5.5.0, @graphql-codegen/typescript@4.1.1...
3 years ago

Minor Changes

  • d6c2d4c: Allow declaring Argument and InputType field mappings based on directive annotations.

    WARNING: Using this option does only change the type definitions.

    For actually ensuring that a type is correct at runtime you will have to use schema transforms (e.g. with @graphql-tools/utils mapSchema) that apply those rules! Otherwise, you might end up with a runtime type mismatch which could cause unnoticed bugs or runtime errors.

    Please use this configuration option with care!

    plugins:
      config:
        directiveArgumentAndInputFieldMappings:
          asNumber: number
    directive @asNumber on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
    
    input MyInput {
      id: ID! @asNumber
    }
    
    type User {
      id: ID!
    }
    
    type Query {
      user(id: ID! @asNumber): User
    }

    Usage e.g. with typescript-resolvers

    const Query: QueryResolvers = {
      user(_, args) {
        // args.id is of type 'number'
      },
    };
  • 8261e41: Make futureProofEnums option work for all enum output types, (it worked only with enumsAsTypes)

Patch Changes

  • Updated dependencies [d6c2d4c]
  • Updated dependencies [feeae1c]
  • Updated dependencies [5086791]
    • @graphql-codegen/visitor-plugin-common@2.2.0

Don't miss a new graphql-code-generator release

NewReleases is sending notifications on new releases.