Git Product home page Git Product logo

Comments (5)

MountCloud avatar MountCloud commented on July 16, 2024

@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.

yfhuang521 avatar yfhuang521 commented on July 16, 2024

@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)这段就查询不了
image
image
这个是代码
@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.

yfhuang521 avatar yfhuang521 commented on July 16, 2024

@MountCloud 能帮我确认下吗?
加.addObjectParameter("block", blockMap)这段就查询不了
image
image
这个是代码
@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.

yfhuang521 avatar yfhuang521 commented on July 16, 2024

@MountCloud
image
image
这是在MountCloud/graphql-client项目源码里面测试的,可以得到结果。但是引入 jar到项目就调用不了

from graphql-client.

yfhuang521 avatar yfhuang521 commented on July 16, 2024

@MountCloud
问题已解决,缺少jar包:jackson-datatype-jdk8
感谢!!!!!

from graphql-client.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.