【问题标题】:karate framework graphql error on standalone [duplicate]独立的空手道框架graphql错误[重复]
【发布时间】:2021-06-30 23:45:04
【问题描述】:
I have a simple graphql which works well in the maven build but getting error when executed  as a feature file with the standalone karate jar.

这是请求中使用的graphql

getCustomerById.graphqls
-----------------------
query{
    getCustomerById(custid:  "12345"){
    custid
    firstname
    lastname
    address1_text
    address2_text
    city_text
    state_text
    zip_text
}
}
-------------------------

#特征文件 graphql.feature

* configure ssl = { keyStore: 'classpath:customer/test.pfx', keyStorePassword: 'test123', keyStoreType: 'pkcs12' }
Given url 'https://<IT_URL>/graphql-data/v1/graphql'
* def customerRequest = read('getCustomerById.graphqls')
And def variables = { customerid: '123456'}
And request { query: '#(query)', variables: '#(variables)' }
When method post
Then status 200

* print 'Response ==>', response

getting the following error
======
18:31:42.699 [main]  WARN  com.intuit.karate.JsonUtils - object to json serialization failure, trying alternate approach: [B cannot be cast to [Ljava.lang.Object;
18:31:42.701 [main]  DEBUG com.intuit.karate - request:
2 > POST https://<ITURL>/graphql-data/v1/graphql
2 > Content-Type: application/json; charset=UTF-8
2 > Content-Length: 62
2 > Host: it-xxx-dns.com
2 > Connection: Keep-Alive
2 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_291)
2 > Accept-Encoding: gzip,deflate
{"variables":{"customerId":"792798178595168"},"query":"[B@7ca8d498"}

18:31:43.060 [main]  DEBUG com.intuit.karate - response time in milliseconds: 357
2 < 200
2 < Date: Wed, 30 Jun 2021 23:31:42 GMT
2 < Content-Type: application/json;charset=UTF-8
2 < Content-Length: 109
2 < Connection: keep-alive
2 < Access-Control-Allow-Origin: *
2 < Access-Control-Allow-Methods: *
2 < Access-Control-Max-Age: 3600
2 < Access-Control-Allow-Headers: authorization, content-type, xsrf-token
2 < Access-Control-Expose-Headers: xsrf-token
2 < Vary: Origin
2 < Vary: Access-Control-Request-Method
2 < Vary: Access-Control-Request-Headers
2 < Strict-Transport-Security: max-age=15724800; includeSubDomains
2 < Set-Cookie: INGRESSCOOKIE=1625095903.954.332.448531; Domain=it-i3-xxx-dns.com; Secure
{"errors":[{"description":"Invalid Syntax : offending token '[' at line 1 column 1","error_code":"400-900"}]}
18:31:43.061 [main]  INFO  com.intuit.karate - [print] Response ==> {
  "errors": [
    {
      "description": "Invalid Syntax : offending token '[' at line 1 column 1",
      "error_code": "400-900"
    }
  ]
}

======

能否请您告诉我代码有什么问题。是因为 SSL 和传递 pfx 文件,它在独立 jar 中的行为不同。我无法找到,但它在 maven 构建中工作得非常好

【问题讨论】:

    标签: graphql karate


    【解决方案1】:

    是的,在独立模式下,最好使用file: 而不是classpath:,除非您知道如何正确设置类路径。

    请阅读此内容以获取更多信息并尝试解决此问题:https://stackoverflow.com/a/58398958/143475

    【讨论】:

    • 更改为 file: 模式,但仍然出现相同的错误。文件路径没问题(我没有得到 filenotfound 异常)。* configure ssl = { keyStore: 'file:src/features/email/test.pfx', keyStorePassword: 'test123', keyStoreType: 'pkcs12' }
    • @KumaraSubramanian 我放弃了。贡献代码(推荐)或遵循这个过程:github.com/intuit/karate/wiki/How-to-Submit-an-Issue
    • 当我替换从文件中读取 graphql 以将查询作为 graphql.feature 中的“文本查询”时,它起作用了。我不确定将 graphql 作为文件读取并设置请求有什么问题。另一个问题是我已经硬编码了客户 ID 的值。我试图将它作为“”中的变量提供,但是当打印查询时,我没有得到值,而是“”。如何在文本查询中传递变量? .
    • 我明白了。它适用于替换...看到您对另一个类似问题的回答
    猜你喜欢
    • 2021-11-09
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多