typescript 无法将类型“DataObject”赋值给类型“DataObject”|文档节点|未定义'

a14dhokn  于 2023-05-19  发布在  TypeScript
关注(0)|答案(2)|浏览(117)

我试图为我的graphql 'route'写一个测试,我遇到了一些错误。这个路由在graphql playground中运行得很好,但在我的测试中,我得到了错误Type 'DocumentNode' is not assignable to type 'string | DocumentNode | undefined'.
我的测试看起来像这样:

错误是这样的:

w1e3prcc

w1e3prcc1#

对于在这里结束的其他人,当我忘记将gql添加到查询中时,我得到了错误Type 'string' is not assignable to type 'DocumentNode | TypedDocumentNode<unknown, { arguments: { id: string; }; }> apollo
是的

export const explainFailure = ` // forgot to add gql
query ($arguments: ExecutionExplainArguments!) {
    execution(arguments: $arguments) {
        id

    }
}
`;
6ljaweal

6ljaweal2#

尝试从导入graphQL客户端的同一个包中导入gql,这样当涉及到gql/nodeDocument时,它们就可以完全匹配类型。

相关问题