最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - Type 'string' is not assignable to GraphQL type - Stack Overflow

programmeradmin7浏览0评论

I am writing a resolve for an object defined via Graphql. Despite the response returned from a query being correct, typescript keeps giving this error

 Types of property 'code' are incompatible.
                Type 'string' is not assignable to type GraphQLCode.

Here is how i am trying to populate the data to be resolved by the resolver

const myArray: {
      code: string;
      ...other fields
    }[] = [];

myArray.push({
        code: codeMapper[code as keyof typeof codeMapper],
        ...other fields
      });

Here is my graphQL type

enum GraphQLCode {
  SOME_VALUES
}
发布评论

评论列表(0)

  1. 暂无评论