GraphQL中的空手道替换 [英] Karate replace in graphql
问题描述
我不确定为什么替换无法正常工作.我有一个graphql查询:
I am not sure why replace is not working. I have a graphql query:
mutation updateLocation{
updateLocation(input: {
address:"<address>",
id:"<storeID>",
name:"<name>",
workingHours: [
{
closingTime:"<closingTime>",
isClosed:false,
openingTime:"<openingTime>"
}
.......
在功能文件中我有这个:
And in feature file I have this:
Given def query = read ('classpath:graphQL/updateStore.graphql')
* replace query.address = "<address>"
* replace query.regionId = "<regionId>"
* replace query.name = "<name>"
* replace query.closingTime = "<closingTime>"
* replace query.openingTime = "<openingTime>"
* replace query.storeID = storeId
And request { query : '#(query)'}
When method post
Then status 200
Examples:
|address |regionId |name |closingTime |openingTime |
|Adrs1 |286 |st1 |20:00 |10:00 |
替换适用于地址,区域ID和名称,但不适用于关闭时间或开放时间,这两个值保持为空.
The replace works for address, regionid, and name but it does not work for closing time or opening time, these two values stay empty.
如果我在后台这样定义标头:
Also if I define header in background like this:
Given header Authorization = 'Bearer ' + token
在相同的情况下,我仍然必须为每个请求添加此行,或者我丢失了什么?
I still have to add this line for each request in the same scenario, or I have been missing something?
推荐答案
为我工作:
* def query = 'closingTime:"<closingTime>"'
* replace query.closingTime = '20:00'
* match query == 'closingTime:"20:00"'
因此,请遵循以下过程: https://github.com/intuit/karate/wiki/如何提交问题
So please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
请注意, *替换query.closingTime = closeingTime
应该有效.我建议通过在 Examples
列中使用不同的名称来避免混淆.
Note that * replace query.closingTime = closingTime
should work. I recommend avoiding confusion by using different names for the Examples
columns.
这篇关于GraphQL中的空手道替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!