public class Query extends Object
| Constructor and Description |
|---|
Query(String graphqlEndpoint)
This constructor expects the URI of the GraphQL server.
|
Query(String graphqlEndpoint,
SSLContext sslContext,
HostnameVerifier hostnameVerifier)
This constructor expects the URI of the GraphQL server.
|
| Modifier and Type | Method and Description |
|---|---|
Builder |
getHelloResponseBuilder()
Get the
ObjectResponse.Builder for the String, as expected by the hello query. |
String |
hello(ObjectResponse objectResponse,
String name)
This method is expected by the graphql-java framework.
|
String |
hello(String queryResponseDef,
String name)
This method is expected by the graphql-java framework.
|
public Query(String graphqlEndpoint)
graphqlEndpoint - the http URI for the GraphQL endpointpublic Query(String graphqlEndpoint, SSLContext sslContext, HostnameVerifier hostnameVerifier)
SSLContext and HostnameVerifier are regular Java stuff. You'll find lots of documentation on the web.
The StarWars sample is based on the http://www.thinkcode.se/blog/2019/01/27/a-jersey-client-supporting-https blog.
But this sample implements a noHostVerification, which of course, is the simplest but the safest way to go.graphqlEndpoint - the https URI for the GraphQL endpointsslContext - hostnameVerifier - public String hello(String queryResponseDef, String name) throws GraphQLExecutionException, GraphQLRequestPreparationException
String
GraphQL type. It can be something like "{ id name }", if you want these fields of this type. Please take a look at
the StarWars, Forum and other samples for more complex queries.queryResponseDef - The response definition of the query, in the native GraphQL format (see here above)episode - Parameter 1 of this queryIOExceptionGraphQLRequestPreparationException - When an error occurs during the request preparation, typically when building the
ObjectResponseGraphQLExecutionException - When an error occurs during the request execution, typically a network error, an error from the
GraphQL server or if the server response can't be parsedpublic String hello(ObjectResponse objectResponse, String name) throws GraphQLExecutionException
objectResponse - The definition of the response format, that describes what the GraphQL server is expected to returnepisode - IOExceptionGraphQLExecutionException - When an error occurs during the request execution, typically a network error, an error from the
GraphQL server or if the server response can't be parsedpublic Builder getHelloResponseBuilder() throws GraphQLRequestPreparationException
ObjectResponse.Builder for the String, as expected by the hello query.GraphQLRequestPreparationExceptionCopyright © 2019. All rights reserved.