@ProviderType
public interface GraphqlClient
| Modifier and Type | Method and Description |
|---|---|
<T,U> GraphqlResponse<T,U> |
execute(GraphqlRequest request,
Type typeOfT,
Type typeOfU)
Executes the given GraphQL request and deserializes the response data based on the types T and U.
|
<T,U> GraphqlResponse<T,U> |
execute(GraphqlRequest request,
Type typeOfT,
Type typeOfU,
RequestOptions options)
Executes the given GraphQL request and deserializes the response data based on the types T and U.
|
GraphqlClientConfiguration |
getConfiguration()
Returns the complete configuration of the GraphQL client.
|
String |
getGraphQLEndpoint()
Returns the URL of the used GraphQL server endpoint.
|
String |
getIdentifier()
Returns the identifier of this GraphQL client and backing OSGi service.
|
String getIdentifier()
cq:graphqlClient property.String getGraphQLEndpoint()
GraphqlClientConfiguration getConfiguration()
<T,U> GraphqlResponse<T,U> execute(GraphqlRequest request, Type typeOfT, Type typeOfU)
GraphqlResponse<MyData, MyError> response = graphqlClient.execute(request, MyData.class, MyError.class); MyData data = response.getData(); List<MyError> errors = response.getErrors();To specify a generic type (usually for the type T), one can use the
TypeToken class. For example:
Type typeOfT = new TypeToken<List<String>>() {}.getType();
GraphqlResponse<List<String>, MyError> response = graphqlClient.execute(request, typeOfT, MyError.class);
List<String> data = response.getData();
T - The generic type of the 'data' object in the JSON GraphQL response.U - The generic type of the elements of the 'errors' array in the JSON GraphQL response.request - The GraphQL request.typeOfT - The type of the expected GraphQL response 'data' field.typeOfU - The type of the elements of the expected GraphQL response 'errors' field.RuntimeException - if the GraphQL HTTP request does not return 200 or if the JSON response cannot be parsed or deserialized.<T,U> GraphqlResponse<T,U> execute(GraphqlRequest request, Type typeOfT, Type typeOfU, RequestOptions options)
GraphqlResponse<MyData, MyError> response = graphqlClient.execute(request, MyData.class, MyError.class); MyData data = response.getData(); List<MyError> errors = response.getErrors();To specify a generic type (usually for the type T), one can use the
TypeToken class. For example:
Type typeOfT = new TypeToken<List<String>>() {}.getType();
GraphqlResponse<List<String>, MyError> response = graphqlClient.execute(request, typeOfT, MyError.class);
List<String> data = response.getData();
T - The generic type of the 'data' object in the JSON GraphQL response.U - The generic type of the elements of the 'errors' array in the JSON GraphQL response.request - The GraphQL request.typeOfT - The type of the expected GraphQL response 'data' field.typeOfU - The type of the elements of the expected GraphQL response 'errors' field.options - An object holding options that can be set when executing the request.RuntimeException - if the GraphQL HTTP request does not return 200 or if the JSON response cannot be parsed or deserialized.Copyright © 2021 Adobe. All rights reserved.