Graphql 为什么空手道会从我的领域名称前面去掉字符?
我的一次空手道测试有点奇怪。我继承了不少(而不是自己写的),它们大多都很好用。我的应用程序使用GraphQL,我正在更改现有的变异函数以添加参数。新参数是定义如下的Graphql 为什么空手道会从我的领域名称前面去掉字符?,graphql,karate,Graphql,Karate,我的一次空手道测试有点奇怪。我继承了不少(而不是自己写的),它们大多都很好用。我的应用程序使用GraphQL,我正在更改现有的变异函数以添加参数。新参数是定义如下的DestinationInput列表: createScheduledTitles(titles: [ScheduledTitleInput!]!, destinations: [DestinationInput]!): [ScheduledTitle!]! 这是我在空手道脚本中设置参数的方式: * def inpu
DestinationInput
列表:
createScheduledTitles(titles: [ScheduledTitleInput!]!, destinations: [DestinationInput]!): [ScheduledTitle!]!
这是我在空手道脚本中设置参数的方式:
* def input =
"""
{titles: [ {
...
],
destinations: [
{
'destinationType': "od",
'brightcovePublish': "true"
}
]
}
"""
这会被服务器端(java)拒绝,原因是:
当然可以,但我提供的是“destinationType”而不是“SteniationType”。当我查看发送内容的日志时,我看到了以下内容:
"destinations": [
{
"stinationType": "od",
"ightcovePublish": "true"
}
]
嗯?那些最初的角色去哪里了?此后,我在字段名和参数上尝试了各种引号组合(双引号、单引号、无引号)。我尝试了不同的行格式等。一些细微的差异,一些组合在字段名中留下引号,因此我将
stinationtype\'
视为错误的字段名,有时它会从前面咬下更多的字母。我已经重新键入了字段名,以防我在其中编辑了一些隐藏字符。到目前为止,没有什么能使我成功。我有其他类似的工作示例,我复制了它们的格式,但仍然没有乐趣。无论发生什么,都是在客户端发生的,因为日志在发送时显示了错误的字段名。有人知道我做错了什么吗?这里是空手道的开发者-这很奇怪,从来没有见过这样的事情。请记住,这可能是一个真正的服务器端错误-但我想您已经查看了请求/http日志
在没有看到整个项目结构的情况下,我的另一个猜测是,可能有一些定制Java/JS代码正在预处理请求,这在GraphQL项目中很常见。尝试形成一个有效的卷曲请求,第2步是将其转换为一个简单的(硬编码的)空手道测试。如果你能管理好这个过程,我们可以看看:
但我只是尝试在一个可以复制的测试中使用您的示例JSON(甚至HTTP POST)。因此,请尝试将其粘贴到新的场景中:
Scenario:
* def input =
"""
{titles: [
{}
],
destinations: [
{
'destinationType': "od",
'brightcovePublish': "true"
}
]
}
"""
* print input
* url 'https://httpbin.org/post'
* request input
* method post
其结果是:
14:26:59.370 [main] INFO com.intuit.karate - [print] {
"titles": [
{
}
],
"destinations": [
{
"destinationType": "od",
"brightcovePublish": "true"
}
]
}
14:26:59.614 [main] DEBUG com.intuit.karate - request:
1 > POST https://httpbin.org/post
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 84
1 > Content-Type: application/json; charset=UTF-8
1 > Host: httpbin.org
1 > User-Agent: Apache-HttpClient/4.5.11 (Java/1.8.0_231)
{"titles":[{}],"destinations":[{"destinationType":"od","brightcovePublish":"true"}]}
14:27:00.890 [main] DEBUG com.intuit.karate - response time in milliseconds: 1274.99
1 < 200
1 < Access-Control-Allow-Credentials: true
1 < Access-Control-Allow-Origin: *
1 < Connection: keep-alive
1 < Content-Length: 696
1 < Content-Type: application/json
1 < Date: Thu, 13 Feb 2020 08:57:00 GMT
1 < Server: gunicorn/19.9.0
{
"args": {},
"data": "{\"titles\":[{}],\"destinations\":[{\"destinationType\":\"od\",\"brightcovePublish\":\"true\"}]}",
"files": {},
"form": {},
"headers": {
"Accept-Encoding": "gzip,deflate",
"Content-Length": "84",
"Content-Type": "application/json; charset=UTF-8",
"Host": "httpbin.org",
"User-Agent": "Apache-HttpClient/4.5.11 (Java/1.8.0_231)",
"X-Amzn-Trace-Id": "Root=1-5e450f5c-18d2618834da3a7afdd3402a"
},
"json": {
"destinations": [
{
"brightcovePublish": "true",
"destinationType": "od"
}
],
"titles": [
{}
]
},
"origin": "103.15.250.10",
"url": "https://httpbin.org/post"
}
14:26:59.370[main]INFO com.intuit.karate-[print]{
“头衔”:[
{
}
],
“目的地”:[
{
“destinationType”:“od”,
“brightcovePublish”:“真实”
}
]
}
14:26:59.614[main]调试com.intuit.karate-请求:
1>职位https://httpbin.org/post
1>接受编码:gzip,deflate
1>连接:保持活动状态
1>内容长度:84
1>内容类型:application/json;字符集=UTF-8
1>主机:httpbin.org
1>用户代理:Apache HttpClient/4.5.11(Java/1.8.0_231)
{“标题”:[{}],“目的地”:[{“目的地类型”:“od”,“brightcovePublish”:“true”}]}
14:27:00.890[main]DEBUG com.intuit.karate-响应时间(毫秒):1274.99
1 < 200
1<访问控制允许凭据:true
1<访问控制允许原点:*
1<连接:保持活动
1<内容长度:696
1<内容类型:应用程序/json
1<日期:周四,2020年2月13日08:57:00 GMT
1<服务器:gunicorn/19.9.0
{
“args”:{},
“数据:“{\”标题\“:[{}],“目的地\“:[{\”目的地类型\“:\”od\”,“brightcovePublish\”:\”真实\“}],
“文件”:{},
“形式”:{},
“标题”:{
“接受编码”:“gzip,deflate”,
“内容长度”:“84”,
“内容类型”:“应用程序/json;字符集=UTF-8”,
“主机”:“httpbin.org”,
“用户代理”:“Apache HttpClient/4.5.11(Java/1.8.0_231)”,
“X-Amzn-Trace-Id”:“根=1-5e450f5c-18d2618834da3a7afdd3402a”
},
“json”:{
“目的地”:[
{
“brightcovePublish”:“true”,
“destinationType”:“od”
}
],
“头衔”:[
{}
]
},
“来源”:“103.15.250.10”,
“url”:”https://httpbin.org/post"
}
这里是空手道的开发者-这很奇怪,从未见过这样的事情。请记住,这可能是一个真正的服务器端错误-但我想您已经查看了请求/http日志
在没有看到整个项目结构的情况下,我的另一个猜测是,可能有一些定制Java/JS代码正在预处理请求,这在GraphQL项目中很常见。尝试形成一个有效的卷曲请求,第2步是将其转换为一个简单的(硬编码的)空手道测试。如果你能管理好这个过程,我们可以看看:
但我只是尝试在一个可以复制的测试中使用您的示例JSON(甚至HTTP POST)。因此,请尝试将其粘贴到新的场景中:
Scenario:
* def input =
"""
{titles: [
{}
],
destinations: [
{
'destinationType': "od",
'brightcovePublish': "true"
}
]
}
"""
* print input
* url 'https://httpbin.org/post'
* request input
* method post
其结果是:
14:26:59.370 [main] INFO com.intuit.karate - [print] {
"titles": [
{
}
],
"destinations": [
{
"destinationType": "od",
"brightcovePublish": "true"
}
]
}
14:26:59.614 [main] DEBUG com.intuit.karate - request:
1 > POST https://httpbin.org/post
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 84
1 > Content-Type: application/json; charset=UTF-8
1 > Host: httpbin.org
1 > User-Agent: Apache-HttpClient/4.5.11 (Java/1.8.0_231)
{"titles":[{}],"destinations":[{"destinationType":"od","brightcovePublish":"true"}]}
14:27:00.890 [main] DEBUG com.intuit.karate - response time in milliseconds: 1274.99
1 < 200
1 < Access-Control-Allow-Credentials: true
1 < Access-Control-Allow-Origin: *
1 < Connection: keep-alive
1 < Content-Length: 696
1 < Content-Type: application/json
1 < Date: Thu, 13 Feb 2020 08:57:00 GMT
1 < Server: gunicorn/19.9.0
{
"args": {},
"data": "{\"titles\":[{}],\"destinations\":[{\"destinationType\":\"od\",\"brightcovePublish\":\"true\"}]}",
"files": {},
"form": {},
"headers": {
"Accept-Encoding": "gzip,deflate",
"Content-Length": "84",
"Content-Type": "application/json; charset=UTF-8",
"Host": "httpbin.org",
"User-Agent": "Apache-HttpClient/4.5.11 (Java/1.8.0_231)",
"X-Amzn-Trace-Id": "Root=1-5e450f5c-18d2618834da3a7afdd3402a"
},
"json": {
"destinations": [
{
"brightcovePublish": "true",
"destinationType": "od"
}
],
"titles": [
{}
]
},
"origin": "103.15.250.10",
"url": "https://httpbin.org/post"
}
14:26:59.370[main]INFO com.intuit.karate-[print]{
“头衔”:[
{
}
],
“目的地”:[
{
“destinationType”:“od”,
“brightcovePublish”:“真实”
}
]
}
14:26:59.614[main]调试com.intuit.karate-请求:
1>职位https://httpbin.org/post
1>接受编码:gzip,deflate
1>连接:保持活动状态
1>内容长度:84
1>内容类型:application/json;字符集=UTF-8
1>主机:httpbin.org
1>用户代理:Apache HttpClient/4.5.11(Java/1.8.0_231)
{“标题”:[{}],“目的地”:[{“目的地类型”:“od”,“brightcovePublish”:“true”}]}
14:27:00.890[main]DEBUG com.intuit.karate-响应时间(毫秒):1274.99
1 < 200
1<访问控制允许凭据:true
1<访问控制允许原点:*
1<连接:保持活动
1<内容长度:696
1<内容类型:应用程序/json
1<日期:周四,2020年2月13日08:57:00 GMT
1<服务器:gunicorn/19.9.0
{
“args”:{},
“数据:“{\”标题\“:[{}],“目的地\“:[{\”目的地类型\“:\”od\”,“brightcovePublish\”:\”真实\“}],
“文件”:{},
“形式”:{},
“标题”:{
“接受编码”:“gzip,deflate”,
“内容长度”:“84”,
“内容类型”:“应用程序/json;字符集=UTF-8”,
“主机”:“httpbin.org”,
“用户代理”:“Apache HttpClient/4.5.11(Java/1.8.0_231)”,
“X-Amzn-Trace-Id”:“根=1-5e450f5c-18d2618834da3a7afdd3402a”
},
“json”:{
“目的地”:[
{
“brightcovePublish”:“true”,
“destinationType”:“od”
}
],
“头衔”:[
{}
]
},
“来源”:“103.15.250.10”,
“url”:”https://httpbin.org/post"
}
Th