public class GraphqlClientImpl extends Object implements GraphqlClient
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.http.client.HttpClient |
client |
| Constructor and Description |
|---|
GraphqlClientImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
activate(GraphqlClientConfiguration configuration) |
protected void |
deactivate() |
<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.
|
public void activate(GraphqlClientConfiguration configuration) throws Exception
Exceptionprotected void deactivate()
public String getIdentifier()
GraphqlClientcq:graphqlClient property.getIdentifier in interface GraphqlClientpublic String getGraphQLEndpoint()
GraphqlClientgetGraphQLEndpoint in interface GraphqlClientpublic GraphqlClientConfiguration getConfiguration()
GraphqlClientgetConfiguration in interface GraphqlClientpublic <T,U> GraphqlResponse<T,U> execute(GraphqlRequest request, Type typeOfT, Type typeofU)
GraphqlClientGraphqlResponse<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();
execute in interface GraphqlClientT - 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.public <T,U> GraphqlResponse<T,U> execute(GraphqlRequest request, Type typeOfT, Type typeofU, RequestOptions options)
GraphqlClientGraphqlResponse<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();
execute in interface GraphqlClientT - 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.Copyright © 2021 Adobe. All rights reserved.