GraphQL返回分页对象

private GraphQLOutputType testUserOutputType;
    private GraphQLOutputType pageType;
    
    private void initOutputType(){
        testUserOutputType = newObject()
                .name("TestVo")
                .field(newFieldDefinition().name("uno").type(GraphQLString).build())
                .field(newFieldDefinition().name("uname").type(GraphQLString).build())
                .field(newFieldDefinition().name("age").type(GraphQLInt).build())
                .field(newFieldDefinition().name("sex").type(GraphQLInt).build()).build();

        pageType = getOutputType(testUserOutputType);
    }
    
    private GraphQLOutputType getOutputType(GraphQLOutputType outputType){
        return newObject()
                .name("outputType")
                .field(newFieldDefinition().name("pageNo").type(GraphQLInt))
                .field(newFieldDefinition().name("pageSize").type(GraphQLInt))
                .field(newFieldDefinition().name("totalCount").type(GraphQLInt))
                .field(newFieldDefinition().name("list").type(new GraphQLList(outputType))).build();
    }
public class PageVo {

    private int pageNo = 1;
    private int pageSize = 10;
    private int totalCount = 0;
    
    private Object list;
    
}

 

访问:

{testPage(age:20,pageNo:1){pageNo,pageSize,totalCount,list{uno,uname,age}}}

返回结果:

 

posted @ 2017-04-08 17:36  yshy  阅读(2902)  评论(2编辑  收藏  举报