Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import-types preset not working with typescript-vue-urql #6303

Closed
hognevevle opened this issue Jul 12, 2021 · 1 comment
Closed

import-types preset not working with typescript-vue-urql #6303

hognevevle opened this issue Jul 12, 2021 · 1 comment

Comments

@hognevevle
Copy link

Describe the bug
When using the import-types preset, the file generated by typescript-vue-urql doesn't populate the correct type references.

Example:
CleanShot 2021-07-12 at 22 19 17

Working code generated by typescript-vue-apollo
CleanShot 2021-07-12 at 22 19 42

As you can see, there is a missing Types. prefix in the Urql code. The generated file does indeed have an import of this (import * as Types from './graphql';), but the import is never used.

My codegen.js config file:

module.exports = {
  schema: [
    {
      "https://myapi": {
        headers: {
          //
        }
      }
    }
  ],
  documents: [
    "./src/**/*.graphql",
    "./src/**/queries/*",
    "./src/**/mutations/*",
    "./src/**/subscriptions/*",
    "./src/**/fragments/*"
  ],
  overwrite: true,
  generates: {
    "./src/generated/graphql.ts": {
      plugins: ["typescript", "typescript-operations"],
      config: {
        skipTypename: false
      }
    },
    "./src/generated/graphql-apollo.ts": {
      preset: "import-types",
      presetConfig: {
        typesPath: "./graphql"
      },
      plugins: ["typescript-vue-apollo"],
      config: {
        skipTypename: false,
        withCompositionFunctions: true,
        vueCompositionApiImportFrom: "vue"
      }
    },
    "./src/generated/graphql-urql.ts": {
      preset: "import-types",
      presetConfig: {
        typesPath: "./graphql"
      },
      plugins: ["typescript-vue-urql"],
      config: {}
    }
  }
};

Environment:

    "@graphql-codegen/cli": "^1.21.3",
    "@graphql-codegen/import-types-preset": "^1.18.5",
    "@graphql-codegen/introspection": "^1.18.1",
    "@graphql-codegen/typescript": "^1.21.1",
    "@graphql-codegen/typescript-operations": "^1.17.15",
    "@graphql-codegen/typescript-vue-apollo": "^2.3.3",
    "@graphql-codegen/typescript-vue-urql": "^1.0.2",
@hognevevle
Copy link
Author

After adding typesPrefix: 'Types.' to the config of typescript-vue-urql, it now works. Not sure if this should still be considered as a bug, although there seems to be some differing behaviour. Close at will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants