使用指令解析可为空的字段

时间:2019-10-07 15:07:10

标签: 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 Response {
  message: String
}

type Query {
  hello(request: Request): Response
}

如果expr是非空字符串,则效果很好。我希望即使expr为空,也要调用我的指令。

请告诉我如何?

0 个答案:

没有答案