我正在尝试使用空手道和graphql创建多部分方案-使用响应形成下一个查询。我已经仔细阅读了文档,但似乎没有任何意义。
我查看了显示“给定路径...”的文档,然后作为get运行第二个查询,但是我需要使用相同的路径
我正在尝试执行以下操作:
authId
-在后台使用对包含登录名的另一个功能文件的“调用读取”操作来完成workId
workId
运行变异graphql并更改数据库出于安全原因,我无法发布确切的架构和代码,但是,让您对我要执行的操作含糊不清:
Background:
* url serverBaseUri
* def signIn = call read('classpath:somepath/to_login.feature') { username: 'abc', password: '123', result: true }
* def sessionAccessId = signIn.responseHeaders['set-cookie'][0]
* header Cookie = sessionAccessId
Scenario: 'Multi Lookup Value test'
* def reqID = "32443rw"
### Send query to get work id from request id as its dynamic and is required to modify the request.
* def query =
"""
query {
RequestById(id: "<reqID>"){
workId
otherNotes
}
}
"""
Given request { query: '#(query)' }
When method post
Then status 200
#### Extract work id from response
* def wkId = response.data.RequestById.workId
### populate 'otherNotes' and 'assignee' for workflow
* def queryMutate =
"""
mutation {
ModifyRequest(
requestId: "<reqID>"
workId: "<wkId>",
assignee: "testUser"
otherNotes: "test"
}
"""
Given request { query: '#(queryMutate)' }
When method post
Then status 200
And match $ ==
"""
{
"data": {
"completeRequest": true
}
}
"""
### Verify query changed successfully
* def validateMutationsWorked =
"""
query {
RequestById(id: "<reqID>"){
workflowId
otherNotes
}
}
"""
Given request { query: '#(validateMutationsWorked)' }
When method post
Then status 200
And match $ ==
"""
{
"data": {
"Requests": [
{
"requestId": "32443rw",
"workId": "abc",
"assignee": null,
}
]
}
}
"""
因此,从本质上讲,我的场景中有3个给定的语句,需要按顺序执行。希望这更有意义,并添加所需的详细信息。
答案 0 :(得分:0)
请查看replace
关键字:https://github.com/intuit/karate#replace
* def text = 'hello <foo> world'
* replace text.foo = 'bar'
* match text == 'hello bar world'
如果您有queryMutate
,请使用text
。所有这些都在文档中进行了广泛介绍,您应该花点时间阅读它:https://github.com/intuit/karate#text
* def reqID = "32443rw"
* text query =
"""
query {
RequestById(id: "<reqID>") {
workId
otherNotes
}
}
"""
* replace query.reqID = reqID
Given request { query: '#(query)' }