Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Having Multiple Queries in Single Request #113

Open
smfaizalkhan opened this issue Jun 8, 2020 · 1 comment
Open

Having Multiple Queries in Single Request #113

smfaizalkhan opened this issue Jun 8, 2020 · 1 comment

Comments

@smfaizalkhan
Copy link

smfaizalkhan commented Jun 8, 2020

Hi @chemdrew, @realityforge

I have been using this tool for Our Application,We have a requirment to send mulitple queries in Single Reques

{
     xxxOverview (id:"12345") 
     { 
        allocation{
           shares
            }
       assets{
           ticker
             }
       id
     } 

   universeMeta
  {
                   etfs{
                  isin
               }
       asset{
           ticker
       }
   }

}

On debugging found that the request has param for only one class

public GraphQLRequestEntity.RequestBuilder request(Class clazz) {
this.clazz = clazz;
return this;
}

Is it possible to have an OverLoaded Method ,taking multiple params like var args or any colletion

public GraphQLRequestEntity.RequestBuilder request(Class ... clazz)

@smfaizalkhan
Copy link
Author

smfaizalkhan commented Feb 23, 2021

@chemdrew Can you let me know if there is a way to combine multiple request queries and send it across the WIRE as single request.

Right now i'm using as below.

    portFolioRequestEntity = GraphQLRequestEntity.Builder()
                .url(portFolioOverViewProperties.getConnectionUrl())
                .request(PortFolioOverView.class).headers(headers)  
                .arguments(
                        new Arguments("portfolioOverview", new Argument("id", PORTFOLIO_ID)))  
                .build();
        log.debug("requestEntity is {}", portFolioRequestEntity.getRequest());

        universeRequestEntity = GraphQLRequestEntity.Builder()
                .url(portFolioOverViewProperties.getConnectionUrl())
                .request(UniverseMeta.class).headers(headers)
                .build();
        log.debug("requestEntity is {}", universeRequestEntity.getRequest());


        String portFolioOverviewReq = getRequestEntityAsString(portFolioRequestEntity);
        log.debug("portFolioOverviewReq" + portFolioOverviewReq);

        String universeReq = getRequestEntityAsString(universeRequestEntity);
        log.debug("universeReq" + universeReq);

        String portFolioSummaryReq = "{" + portFolioOverviewReq
                + universeReq + "}";
        log.debug("combinedRequest is {}", portFolioSummaryReq);
        portFolioSummaryRequestEntity = GraphQLRequestEntity.Builder()
                .url(portFolioOverViewProperties.getConnectionUrl())
                .request(portFolioSummaryReq).headers(headers)
                .build();

               private String getRequestEntityAsString(GraphQLRequestEntity graphQLRequestEntity) {
            String requestEntityAsString = graphQLRequestEntity.getRequest().trim().replaceAll("query", "");
           return requestEntityAsString.substring(requestEntityAsString.indexOf('{') + 1, requestEntityAsString.length() - 1);
               } 

Is there any other better way to achieve it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant