Class DgsGraphQlClient

java.lang.Object
org.springframework.graphql.client.DgsGraphQlClient

public final class DgsGraphQlClient extends Object
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
  • Method Details

    • getGraphQlClient

      public GraphQlClient getGraphQlClient()
      Return the wrapped GraphQlClient to delegate to.
    • request

      public DgsGraphQlClient.RequestSpec request(com.netflix.graphql.dgs.client.codegen.GraphQLQuery query)
      Start defining a GraphQL request for the given GraphQLQuery.
      Parameters:
      query - the GraphQL query
    • create

      public static DgsGraphQlClient create(GraphQlClient client)
      Create instance that wraps the given GraphQlClient.
      Parameters:
      client - the client to delegate to