[英]How to use different scalar types for one field in graphQL schema?
I have an input type that says:我有一个输入类型,上面写着:
input testInput {
a: String
b: String
c: Boolean
}
I have a situation where field c
can be either String
or Boolean
.我有一种情况,字段
c
可以是String
或Boolean
。 How can i implement the field c
that will accept both String
and Boolean
?如何实现将接受
String
和Boolean
c
Graphql does not support union of scalar types. Graphql 不支持标量类型的联合。 So you can modify it this way
所以你可以这样修改
input testInput { a: String b: String c: hybridType }输入 testInput { a:字符串 b:字符串 c:hybridType }
type cBoolean { content: Boolean }类型 cBoolean { 内容:Boolean }
type cString { content: String }类型 cString { 内容:字符串 }
union hybridType = cBoolean | union hybridType = cBoolean | cString
字符串
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.