USK*_*ity 2 netflix graphql graphql-java netflix-dgs
我们可以如下编写查询解析器层
@DgsData(parentType = "Query", field = "answersByQuestionUuid")
public List<Answer> answersByQuestionUuid(@InputArgument("questionUuid") UUID questionUuid,
@InputArgument("enhancedContent") boolean enhancedContent,
@InputArgument("templateName") String templateName) {
if (enhancedContent) {
return getStructuredAnswersByQuestionUUID(questionUuid.toString(), templateName);
}
return getAnswersByQuestionUUID(questionUuid);
}
Run Code Online (Sandbox Code Playgroud)
如何在解析器中获取 HTTP 标头。
除了 DGS 输入参数之外,您还可以使用@RequestHeaderSpring 框架中的注释来接收 HTTP 请求标头值。例如:
public List<Answer> answersByQuestionUuid(@InputArgument("questionUuid") UUID questionUuid,
@RequestHeader("Content-Type") String contentType) {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2823 次 |
| 最近记录: |