Skip to content

DgsGraphQlClient support for GraphQLMultiQueryRequest #1221

Open
@giridhargg

Description

@giridhargg

Clients should be able to send multiple queries(netflix dgs generated query and projection DTO's) using the DgsGraphQlClient wrapper class? For example, I have below schema:

type Query {
    books: [Book]
    authors: [Author]
}

type Book {
    id: ID
    name: String!
    authors: [Author!]!
}
type Author {
    name: String!
}

The generated DTO's for queries and projections, and the multi-query request will be:

var booksGraphqlQuery = BooksGraphQLQuery.newRequest().build();
var authorsGraphqlQuery = AuthorsGraphQLQuery.newRequest().build();
var booksProjection = BooksProjectionRoot<>().id().name().authors().name();
var authorsProjection = AuthorsProjectionRoot<>().name();

var booksRequest = new GraphQLQueryRequest(booksGraphqlQuery, booksProjection);
var authorsRequest = new GraphQLQueryRequest(authorsGraphqlQuery, authorsProjection);

var multiQueryRequest = new GraphQLMultiQueryRequest(List.of(booksRequest, authorsRequest));

Now I need to send this multi-query request using DgsGraphQlClient for example something like:

var dgsGraphQlClient = DgsGraphQlClient.create(HttpGraphQlClient.builder(webClientBuilder).build());
var response = dgsGraphQlClient.request(multiQueryRequest).executeSync();

But I see it's not supported with it yet. I know there is a work around, using the following code:

var response = dgsGraphQlClient.getGraphQlClient().document(multiQueryRequest.serialize()).executeSync();

But, I am hoping DgsGraphQlClient to do all of the above things, where I will just pass in the DTO's of queries and projections directly as arguments to it.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions