我有一个带有单个端点的spring rest控制器,可以接收所有graphql查询/变异请求。端点如下
@RequestMapping(value="/test", method = RequestMethod.POST)
public ResponseEntity testService(@RequestHeader("user") String userName,
@RequestBody String query) {
ExecutionResult result = graphQL.execute(query);
}
我已经正确设置了我的graphql对象。如何将用户名从请求标头传递到graphql查询,以便数据提取程序可以检索它来更新userModified信息?
不要使用简单的GraphQL#execute(String)
方法,而要使用功能更强大的版本GraphQL#execute(ExecutionInput)
。
例如
ExecutionResult executionResult = graphQL.execute(ExecutionInput.newExecutionInput()
.query(query)
.context(username)
.build());
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句