简体   繁体   中英

how to pass ServletRequest to pojo that does i/o in graphql-java

I need to pass a servlet attribute value to the Query object on a per request basis. I have this much working, but how can I get the real Query object from the qt variable?

    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
    GraphQLSchema schema = getSchemaProvider().getSchema();
    //schema.transform(c -> {});
    GraphQLObjectType t = schema.getQueryType();
    String rootLib = (String) req.getAttribute("ROOTLIB");
    super.service(req, res);
}

extend DefaultQLSchemaProvider and override the getSchema(request:HttpServletRequest):GraphQLSchema method. Then override the GraphQLEndpoint ctor and create the schemaProvider when calling super(GrapQLProvider, ...) ctor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM