public class ObjectResponse extends Object
ObjectResponse itsled contains one or more ObjectResponse, to describe
the Sub-object(s) that should be returned.ObjectResponse can not be created directly. You must use an Builder to create a
ObjectResponse. This Builder allows to easily add fields, which can be scalars or sub-objects. And it
validates for each the GraphQL schema is respected.ObjectResponse:
ObjectResponse: a query ResponsDef is returned by the generated code. For instance, if your
schema contains a QueryType type, a QueryType object will be generated. For each query in the GraphQL schema, this
QueryType object contains two methods: a getter which returns the Builder for this query, and the method wich
actually do the call to the GraphQL server for this query.ObjectResponse: such a ObjectResponse allow you to define what's expected for a
field that is actually an object. This field is a sub-object of the object owning this field. To link such a
ObjectResponse, you'll use the Builder.withSubObject(String, ObjectResponse) or the
Builder.withSubObject(String, String, ObjectResponse) method.BuilderObjectResponse from the generated QueryType (or whatever name you have in your GraphQL
schema for the query object), and its method getXxxxResponseDef, where Xxxx is the name of the query into the
QueryType.Builder, you can call:
ObjectResponse. To get this
ObjectResponse, you'll create a Builder with one of the newSubObjectResponseDefBuilder methods.| Modifier and Type | Method and Description |
|---|---|
void |
appendResponseQuery(StringBuilder sb)
Retrieves the part of the query, which describes the fields that the GraphQL server should return.
|
String |
getFieldAlias() |
Class<?> |
getFieldClass() |
String |
getFieldName() |
static Builder |
newQueryResponseDefBuilder(Class<?> clazz,
String fieldName)
Contruct a new
Builder. |
static Builder |
newQueryResponseDefBuilder(Class<?> clazz,
String fieldName,
String fieldAlias)
Contruct a new
Builder |
static Builder |
newSubObjectBuilder(Class<?> clazz)
Contruct a new
Builder |
public static Builder newQueryResponseDefBuilder(Class<?> clazz, String fieldName) throws GraphQLRequestPreparationException
Builder. You can then call the withField or withSubObject methods toclazz - The Class for which contains the field for which this ObjectResponse defines the expected
response from the GraphQL serverfieldName - The name of the field for which this ObjectResponse defines the expected response from the
GraphQL server. There will be no alias for this field in the request.NullPointerException - If the fieldName is nullGraphQLRequestPreparationException - If the fieldName is not validpublic static Builder newQueryResponseDefBuilder(Class<?> clazz, String fieldName, String fieldAlias) throws GraphQLRequestPreparationException
Builderclazz - The Class for which contains the field for which this ObjectResponse defines the expected
response from the GraphQL serverfieldName - The name of the field for which this ObjectResponse defines the expected response from the
GraphQL serverfieldAlias - The alias for this field. Typically necessay if you want to do two queries of the name within one
server callNullPointerException - If the fieldName is nullGraphQLRequestPreparationException - If the fieldName or the fieldAlias is not validpublic static Builder newSubObjectBuilder(Class<?> clazz)
Buildername - public String getFieldAlias()
public Class<?> getFieldClass()
public String getFieldName()
public void appendResponseQuery(StringBuilder sb)
sb - The StringBuilder where the response must be appendedCopyright © 2019. All rights reserved.