Graphql-code-generator: TS Variable types wrong for operations with default variables

Created on 25 Mar 2019  路  3Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
The types generated for operations with variables that have set defaults are wrong, and force a value.
To Reproduce
Steps to reproduce the behavior:

  1. My GraphQL schema:
extend type Mutation {
  setUserActive(id: ID!, active: Boolean!): Boolean
}
  1. My GraphQL operations:
mutation SetUserActive($id: ID!, $active: Boolean = true) {
  setUserActive(id: $id, active: $active)
}
  1. My codegen.yml config file:
overwrite: true
documents:
  - src/client/**/documents.graphql
schema:
  - src/client/**/*schema.graphql
generates:
  src/client/generated/graphql.ts:
    config:
      avoidOptionals: false
      immutableTypes: true
    plugins:
      - typescript
      - typescript-operations
      - typescript-apollo-angular
  src/client/generated/schema-client.graphql:
    plugins:
      - "schema-ast"

Expected behavior

I expect the generated Variable type to allow active to be optional

Environment:

bug plugins waiting-for-release

All 3 comments

1567 Should fix it

I released a canary version, could you try: 1.0.5-alpha-4b26c306.0+4b26c306?

Fixed in 1.0.5.

Was this page helpful?
0 / 5 - 0 ratings