Class DgsGraphQlClient
java.lang.Object
org.springframework.graphql.client.DgsGraphQlClient
Simple wrapper around a
GraphQlClient that prepares the request
from classes generated with the
DGS Code Generation library.
GraphQlClient client = ... ;
DgsGraphQlClient dgsClient = DgsGraphQlClient.create(client);
List<Book> books = dgsClient.request(new BooksGraphQLQuery())
.projection(new BooksProjectionRoot<>().id().name())
.retrieveSync()
.toEntityList(Book.class);
- Since:
- 1.3.0
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classDeclare options to gather input for a GraphQL request and execute it. -
Method Summary
Modifier and TypeMethodDescriptionstatic DgsGraphQlClientcreate(GraphQlClient client) Create instance that wraps the givenGraphQlClient.Return the wrappedGraphQlClientto delegate to.request(com.netflix.graphql.dgs.client.codegen.GraphQLQuery query) Start defining a GraphQL request for the givenGraphQLQuery.
-
Method Details
-
getGraphQlClient
Return the wrappedGraphQlClientto delegate to. -
request
public DgsGraphQlClient.RequestSpec request(com.netflix.graphql.dgs.client.codegen.GraphQLQuery query) Start defining a GraphQL request for the givenGraphQLQuery.- Parameters:
query- the GraphQL query
-
create
Create instance that wraps the givenGraphQlClient.- Parameters:
client- the client to delegate to
-