Graphql-code-generator: Strict apolloClientVersion value check breaks fragment-matcher

Created on 8 Feb 2020  路  3Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug

Specifying apolloClientVersion as integer for fragment-matcher results in error Extension .ts not supported because strict match against string is used at https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/other/fragment-matcher/src/index.ts#L134

In docs it is specified as integer: https://graphql-code-generator.com/docs/plugins/fragment-matcher#apolloclientversion-string-default-value-2

To Reproduce
Steps to reproduce the behavior:

  1. create configuration for example
overwrite: true
schema: './schema/index.ts'
documents: './graphql/**/*.graphql'
generates:
  './graphql/__generated__/introspectionResult.ts':
    hooks:
      afterOneFileWrite:
        - prettier --write
    config:
      apolloClientVersion: 2
    plugins:
      - fragment-matcher
  1. try to generate schema, you will get Extension .ts not supported.

  2. Then change configuration to

overwrite: true
schema: './schema/index.ts'
documents: './graphql/**/*.graphql'
generates:
  './graphql/__generated__/introspectionResult.ts':
    hooks:
      afterOneFileWrite:
        - prettier --write
    config:
      apolloClientVersion: '2'
    plugins:
      - fragment-matcher
  1. try to generate schema, everything is ok.

Environment:

bug plugins waiting-for-release

All 3 comments

You are right, we should allow more loose type checking for that values because it's coming from the YAML config.

I changed it in: https://github.com/dotansimha/graphql-code-generator/pull/3495
Now both string/number will work .

Can you please try the alpha version? 1.12.3-alpha-1823fb22.25

@dotansimha I tried the version you mentioned and it works OK. 馃憤 Thank you. I'm sorry I didn't provide a PR. I was in a hurry :(

Fixed in v1.13.0

Was this page helpful?
0 / 5 - 0 ratings