next.js Graphql Codegen命名`CreateWithdrawLinkDocument`定义了多次错误

zu0ti5jz  于 2023-06-05  发布在  其他
关注(0)|答案(1)|浏览(131)

我用next.js/react设置了Graphql codegen,并运行了codegen文件,该文件生成了类型脚本类型的代码,但是当我树运行我的next.js应用程序时,它给出了nameMySomeDocumentis defined multiple times错误。
这是我的codegen cofig文件

import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
  overwrite: true,
  schema: [
    "http://1/api/graphql",
    "https://2/graphql",
  ],

  documents: ["./utils/graphql/*.ts"],
  generates: {
    "./utils/generated/": {
      preset: "client",
      plugins: [
        "typescript",
        "typescript-operations",
        "typescript-react-apollo",
      ],
    },
    "./graphql.schema.json": {
      plugins: ["introspection"],
    },
  },
};

export default config.

我有三个单独的文件。我试图删除预设文件,但后来我开始得到这个当我运行codegen

✖ Plugin "typescript-react-apollo" validation failed:

                Plugin "typescript-react-apollo" requires extension to be ".ts" or ".tsx"!

使用预置完美地生成代码,但我在Next.js中出现错误
如何解决此问题。

0s0u357o

0s0u357o1#

我已经通过将路径从**./utils/generated/更改为./utils/generated/graphql.ts**解决了这个问题

相关问题