【发布时间】:2022-11-14 05:11:00
【问题描述】:
我正在尝试使用 Graphql Hot Chocolate 测试我的 Web Api。我阅读了 ChilliCream https://chillicream.com/blog/2019/04/11/integration-tests 的文档,但我有疑问。一些端点使用基于 JWT 的授权,我需要在请求的标头上发送它。 (我还有其他使用标题进行某些操作的方法)
如何使用 Query RequestBuilder 发送一个或多个标头?
我会尝试使用它,我收到了 http 403
IReadOnlyQueryRequest request = QueryRequestBuilder.New()
.SetQuery("query{ clients(where:{state:{eq:ACTIVE}}) { items{ id code date name email desc state created modify } pageInfo{ hasNextPage hasPreviousPage } totalCount } }")
.AddProperty("enviroment", "test")
.AddProperty("authorization", "Bearer token_value")
.Create();
IExecutionResult result = await executor.ExecuteAsync(request);
【问题讨论】:
标签: c# asp.net unit-testing graphql hotchocolate