Comments (5)
@MountCloud
你好请部复杂参数如何查询?
{
pair(id: 50, block:{number:100}) {
id
}
}
这个 block:{number:100}这块参数要怎么传递,多谢
Request可以这样构造
`
//声明block参数,这个可以是map可以是自己的类,有个number属性类型是int或者integer或者long就行
Map<String,Object> blockParam = new HashMap<>();
blockParam.put("number",100);
GraphqlRequest request = new DefaultGraphqlQuery("pair");
//id参数跟block参数一起添加
request.addParameter("id",50)
.addObjectParameter("block",blockParam);
//也可以单独户添加block参数,ObjectParameter可以是map可以是自己的实体类。
request.getRequestParameter().addObjectParameter("block",blockParam);
//result值返回一个id
request.addResultAttributes("id");
`
from graphql-client.
@MountCloud
你好请部复杂参数如何查询?
{
pair(id: 50, block:{number:100}) {
id
}
}
这个 block:{number:100}这块参数要怎么传递,多谢Request可以这样构造
`
//声明block参数,这个可以是map可以是自己的类,有个number属性类型是int或者integer或者long就行 Map<String,Object> blockParam = new HashMap<>(); blockParam.put("number",100); GraphqlRequest request = new DefaultGraphqlQuery("pair"); //id参数跟block参数一起添加 request.addParameter("id",50) .addObjectParameter("block",blockParam); //也可以单独户添加block参数,ObjectParameter可以是map可以是自己的实体类。 request.getRequestParameter().addObjectParameter("block",blockParam); //result值返回一个id request.addResultAttributes("id");
`
加.addObjectParameter("block", blockMap)这段就查询不了
这个是代码
@test
public void pairInfo() {
try {
String url = "https://api.thegraph.com/subgraphs/name/therealsakeswap/sakeswap-subgraph-v2";
GraphqlClient graphqlClient = GraphqlClient.buildGraphqlClient(url);
// block
Map<String, Object> blockMap = new HashMap<String, Object>();
blockMap.put("number", 11149005);
GraphqlQuery query = new DefaultGraphqlQuery("pair");
query.addParameter("id", "0xca3d6a94759cb675f0ac10a76fc0da6ee6bf6e7b").addObjectParameter("block", blockMap);
query.addResultAttributes("id");
System.out.println(query.toString());
GraphqlResponse response = graphqlClient.doQuery(query);
System.out.println(response.getData().toString());
} catch (Exception e) {
e.printStackTrace();
}
}
from graphql-client.
@MountCloud 能帮我确认下吗?
加.addObjectParameter("block", blockMap)这段就查询不了
这个是代码
@test
public void pairInfo() {
try {
String url = "https://api.thegraph.com/subgraphs/name/therealsakeswap/sakeswap-subgraph-v2";
GraphqlClient graphqlClient = GraphqlClient.buildGraphqlClient(url);
// block
Map<String, Object> blockMap = new HashMap<String, Object>();
blockMap.put("number", 11149005);
GraphqlQuery query = new DefaultGraphqlQuery("pair");
query.addParameter("id", "0xca3d6a94759cb675f0ac10a76fc0da6ee6bf6e7b").addObjectParameter("block", blockMap);
query.addResultAttributes("id");
System.out.println(query.toString());
GraphqlResponse response = graphqlClient.doQuery(query);
System.out.println(response.getData().toString());
} catch (Exception e) {
e.printStackTrace();
}
}
from graphql-client.
@MountCloud
这是在MountCloud/graphql-client项目源码里面测试的,可以得到结果。但是引入 jar到项目就调用不了
from graphql-client.
@MountCloud
问题已解决,缺少jar包:jackson-datatype-jdk8
感谢!!!!!
from graphql-client.
Related Issues (16)
- How to execute multi query in one request HOT 4
- kj
- 参数转义错误 HOT 3
- 请求参数中有枚举怎么处理 HOT 1
- 可以增加设置超时时间吗? HOT 1
- where 条件参数怎么传 HOT 12
- Demo的例子有问题
- doMutation 参数组装错误
- input格式如何支持?
- 请问一下filter的这种语句,如何构造 HOT 1
- how to query like this HOT 1
- 当返回类型是String或者Long类型时报错
- 关于请求返回on Type{}怎么用? HOT 2
- Filter Support In GraphQL Query
- ResultAttributtes 类名拼写错误
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-client.