dotansimha / graphql-code-generator-community

MIT License
118 stars 154 forks source link

The `typescript-urql-graphcache` plugin does not respect the `import-types` preset configuration #185

Open AydanGaite opened 2 years ago

AydanGaite commented 2 years ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. My GraphQL schema: N/A

  2. My GraphQL operations: N/A

  3. My codegen.yml config file:

schema: http://192.168.0.11:8080/graphql
documents: 'src/**/*.graphql'

generates:
  ./src/schema.ts:
    hooks:
      afterOneFileWrite:
        - eslint --fix
    plugins:
      - typescript

    config:
      maybeValue: T | undefined
      useTypeImports: true

  ./src/index.ts:
    preset: import-types

    presetConfig:
      typesPath: ./schema
      importTypesNamespace: Schema

    hooks:
      afterOneFileWrite:
        - eslint --fix

    plugins:
      - typescript-operations
      - typescript-resolvers
      - typed-document-node
      - urql-svelte-operations-store
      - typescript-urql-graphcache

    config:
      maybeValue: T | undefined
      useTypeImports: true

  ./src/schema.graphql:
    plugins:
      - schema-ast

Expected behavior Generating typescript-urql-graphcache should generate types with the respected namespace (in this case schema) but instead it ignores it. For example, here is the output generated by another plugin. The namespace is respected (ie. Schema.Address)

export type ResolversTypes = {
  Address: ResolverTypeWrapper<Schema.Address>;
}

Here is the output of typescript-urql-graphcache:

export type GraphCacheKeysConfig = {
  Address?: (data: WithTypename<Address>) => null | string,
}

In this case the namespace is not respected.

Environment:

Urigo commented 2 years ago

Thank you @ka1to1 for sharing! I'm just labeling the issue by the Issue workflow progress. Would you be able to move it forward by sharing a reproduction or even better by creating a failing test?

Psvensso commented 1 year ago

Confirming that this still excists. import-types-preset are not respected.

Psvensso commented 1 year ago

FYI. After 30min looking i found the tests, the community plugins have been moved to https://github.com/dotansimha/graphql-code-generator-community/tree/main/packages/plugins/typescript/urql-graphcache