Graphql 使用指令解析可为空的字段
我正在开发一个名为Graphql 使用指令解析可为空的字段,graphql,graphql-js,Graphql,Graphql Js,我正在开发一个名为bind的GraphQL指令,可以在字段上使用它来解析为另一个值 # This is a simplification of the actual definitions directive @bind(value: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION input Request { expr: String! @bind(value: "/v1.0/std/expr") } type Respon
bind
的GraphQL指令,可以在字段上使用它来解析为另一个值
# This is a simplification of the actual definitions
directive @bind(value: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
input Request {
expr: String! @bind(value: "/v1.0/std/expr")
}
type Response {
message: String
}
type Query {
hello(request: Request): Response
}
如果expr
是一个非空字符串,那么它工作得很好。我希望即使expr
为空,也能调用我的指令
你能告诉我怎么做吗?你是说你想用你的指令强制非空字符串解析为空而不出错吗?@DanielRearden我的意思是如果
expr
是不是空字符串,指令总是被调用。哦,刚才注意到这是一种输入对象类型。隐马尔可夫模型。