简体   繁体   English

无法使用从 GraphQL Codegen 类型导入的枚举值

[英]Cannot use enum values imported from GraphQL Codegen types

Whenever I import enums from graphql-codegen generated types and use their values, the app fails to start.每当我从 graphql-codegen 生成的类型导入枚举并使用它们的值时,应用程序都无法启动。

import { MyEnum } from 'graphql-types.ts';

let x: MyEnum; // This works
x = MyEnum.MY_ENUM_VALUE; // Whenever I use this code, it fails

TypeScript does not show any errors in the code, but the app fails to run showing the error message below. TypeScript 未在代码中显示任何错误,但应用程序无法运行并显示以下错误消息。

Android Bundling failed

SyntaxError: graphql.types.ts: Identifier 'Document' has already been declared.

export const Document = gql`
...

Use export const name = gql query name使用export const name = gql查询名称

instead of: export const Document = gql query your identifier name is likely clashing with an ambient type definition.而不是: export const Document = gql查询您的标识符名称可能与环境类型定义冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Apollo Server:弹出内置“上传”类型以使用 graphql-codegen 生成 TS 类型 - Apollo Server: Eject built in "Upload" Type to generate TS Types with graphql-codegen TypeScript 使用 GraphQL 生成的类型将 Enum 转换为另一个 Emum - TypeScript Convert Enum to another Emum with GraphQL generated types 从反应应用程序向 graphql API 发送枚举 - Send an enum to graphql API from react app 具有多个值和值类型的Javascript枚举 - Javascript enum with multiple values and value types JSDoc中的Intellisense无法用于VSCode中的导入类型 - Intellisense from JSDoc not working for imported types in VSCode 将.graphql中的类型导入到.js文件中 - Import types from .graphql into a .js file 给定一组GraphQL变量类型,是否可以使用客户端架构为该集中的每种类型创建所有有效值的映射 - Given a set of GraphQL variable types, is it possible to use the client schema to create a map of all valid values for each type in the set 如何将自定义标量添加到 GraphQL Codegen? - How to add custom scalars to GraphQL Codegen? 如何使用枚举值作为类型 - How to use enum values as a type 从服务器导入的数据无法使用/访问html文件中嵌入的javascript函数 - Imported data from server cannot use / access javascript functions embedded in html file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM