gpt4 book ai didi

GraphQL - 联合类型给出错误,找不到该类型名称的类

转载 作者:行者123 更新时间:2023-12-04 04:19:25 24 4
gpt4 key购买 nike

在我的 GraphQL 模式文件中,我试图添加一个联合类型,如下所示:

type CoOverrides {
coId: String
type: String
}

type SoOverrides {
soId: String
freeInterval: String
}

union CoOrSoOverrides = CoOverrides | SoOverrides

然后我将它分配给我的类型,如下所示:
type Campaign {
id: ID!
title: String
overrides: [CoOrSoOverrides]
}

但是在启动 graphql 服务器时,我不断收到错误消息:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.coxautodev.graphql.tools.SchemaParser]: Factory method 'schemaParser' threw exception; 
nested exception is com.coxautodev.graphql.tools.SchemaClassScannerError:
Object type 'CoOverrides' is a member of a known union, but no class could be found for that type name. Please pass a class for type 'CoOverrides' in the parser's dictionary.

这究竟是什么以及如何将此类添加到解析器的字典中?

任何帮助表示赞赏。

谢谢。

最佳答案

如错误消息 - 通过 CoOverrides类到字典。

@Configuration
public class SchemaParserConfig {

@Bean
public SchemaParserDictionary schemaParserDictionary() {
return new SchemaParserDictionary()
.add(CoOverrides.class);
}

}

关于GraphQL - 联合类型给出错误,找不到该类型名称的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59783045/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com