【发布时间】:2021-10-24 15:03:38
【问题描述】:
// 我尝试将突变作为 json 发送
val testAPIScenario = scenario("Sample test")
.exec(http("graph ql sample test")
.post("https://demo.com/")
.body(RawFileBody("./src/gatling/resources/graphql/sample.json")).asJson
.header("content-type",value = "application/json")
.check(status.is(200))
)
val testAPIScenario = scenario("Sample test")
.exec(http("graph ql sample test")
.post("https://demo.com/")
.body(StringBody("\"query\":\""+getMutation()+"\",\"variables\":"+getVariables()+"}")).asJson
.header("content-type",value = "application/json")
.check(status.is(200))
)
还尝试使用 ElFileBody 发送它,将突变保存在文本文件中。
只需要知道是否有任何方法可以在加特林体内发送 graphQl 突变
我检查了日志,请求在 graphql 上正常进行,但它给了我 400,我认为有一些格式问题,请指导我
【问题讨论】:
-
不熟悉 gatling 但有 2 件事,1 仔细检查您的端点,大多数 graphql 服务器使用 '
/graphql' 2,使用 curl 或 postman 获取 graphql 内省架构 hasura.io/learn/graphql/intro-graphql/introspection 到仔细检查部署的架构是否符合您的要求 -
我在这里添加了一个虚拟端点,实际端点不同。
-
那么我建议下一步是通过自省获取 graphql 模式,这样您就知道您的端点是正确的,并且您可以看到后端期望的突变形状,请参阅stackoverflow.com/questions/37397886/…