查询内的空手道graphql变量 [英] Karate graphql variables inside query

查看:60
本文介绍了查询内的空手道graphql变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在graphql查询中插入先前定义的变量,但是除了在查询文本之外创建变量然后使用变量进行请求之外,我无法找到任何有关如何执行此操作的示例.

I am trying to insert previously defined variable inside graphql query but I'm not able to find any example on how to do that except creating variables outside of query text and then making request with variables.

在这个示例中,例如我一个问题

There is one problem for me for example in this example

queries: [{type: TERM, match: EQUAL, field: "fieldOne", value: "#(id)"},
          {type: TERM, match: EQUAL, field: "fieldTwo", value: null}]

我只想为graphql查询中的第一个对象插入值#(id).谁能为我提供一些例子或任何建议呢?

I want to insert value #(id) only for the first object in graphql query. Can anyone please provide some example for me or any suggestions on how to do that?

推荐答案

好的,我认为可以直接替换查询中的文本,但是我从空手道文档中找到了解决方案.

Alright I was thinking that it will be possible to directly replace text inside query, but I found solution from karate documentation with.

queries: [{type: TERM, match: EQUAL, field: "fieldOne", value: "<id>"},
      {type: TERM, match: EQUAL, field: "fieldTwo", value: null}]

将ID放在查询文本内的尖括号<>中然后通过调用

enclose id inside query text in angle brackets <> and then replace id inside query with id stored in variable id by calling

* replace query.id = id

这篇关于查询内的空手道graphql变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆