Graphql-code-generator: plugin with string as a config (e.g. add plugin) does not inherit config from parent

Created on 17 Sep 2019  路  3Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug

The add plugin does not inherit the config from its parent. I noticed this while testing #2567 (1.7.1-alpha-b651f2ce.56).

To Reproduce

  packages/product-1/src/graphql/index.tsx:
    documents: "packages/product-1/src/**/*.graphql"
    config:
      skipDocumentsValidation: true
      withHOC: true
      withComponent: true
      withHooks: true
      hooksImportFrom: "react-apollo"
      reactApolloImportFrom: "react-apollo"
    plugins:
      - add: "/* eslint-disable */"
      - "typescript"
      - "@n1ru4l/graphql-codegen-relay-optimizer-plugin"
      - "typescript-operations"
      - "typescript-react-apollo"

Workaround:

  packages/product-1/src/graphql/index.tsx:
    documents: "packages/product-1/src/**/*.graphql"
    config:
      skipDocumentsValidation: true
      withHOC: true
      withComponent: true
      withHooks: true
      hooksImportFrom: "react-apollo"
      reactApolloImportFrom: "react-apollo"
    plugins:
      - add:
          content:
            - "/* eslint-disable */"
          config:
            skipDocumentsValidation: true
      - "typescript"
      - "@n1ru4l/graphql-codegen-relay-optimizer-plugin"
      - "typescript-operations"
      - "typescript-react-apollo"

Additional context

Should every plugin trigger a document validation? I know that documents might change between steps, so this might make sense, however, the add plugin could completely skip validation by default (since it does not interfere with the documents).

bug core waiting-for-release

Most helpful comment

@n1ru4l had some time today, and I wanted to fix that for a long time :D Also, we can now bump version of plugins without bump everything, so we can easily introduce breaking changes in plugins as well.

Fixed it in: https://github.com/dotansimha/graphql-code-generator/pull/4509

All 3 comments

@n1ru4l Yeah it happens because when the parent/child config value is string, we can't really extend it as object :(

I think we need to find a good solution for that.

@n1ru4l had some time today, and I wanted to fix that for a long time :D Also, we can now bump version of plugins without bump everything, so we can easily introduce breaking changes in plugins as well.

Fixed it in: https://github.com/dotansimha/graphql-code-generator/pull/4509

Fixed in @graphql-codegen/[email protected] (also for time plugin)

Was this page helpful?
0 / 5 - 0 ratings