public class Builder extends Object
ObjectResponse, which defines what should appear in the
response from the GraphQL server.| Constructor and Description |
|---|
Builder(Class<?> owningClass,
String fieldName)
Creates a Builder, for a field without alias
|
Builder(Class<?> owningClass,
String fieldName,
String fieldAlias)
Creates a Builder
|
| Modifier and Type | Method and Description |
|---|---|
ObjectResponse |
build()
Returns the built
ObjectResponse. |
static String |
getCamelCase(String name)
Convert the given name, to a camel case name.
|
Builder |
withField(String fieldName)
Adds a scalar field with no alias, to the
ObjectResponse we are building |
Builder |
withField(String fieldName,
String alias)
Adds a scalar field with an alias, to the
ObjectResponse we are building |
Builder |
withInputParameter(InputParameter inputParameter)
Deprecated.
|
Builder |
withInputParameter(String name,
String bindParameterName,
boolean mandatory)
Add an
InputParameter to the current Object Response definition. |
Builder |
withInputParameterHardCoded(String name,
Object value)
Add an
InputParameter to the current Object Response definition. |
Builder |
withInputParameters(List<InputParameter> inputParameters)
Add a list of
InputParameters to the current Object Response definition. |
Builder |
withQueryResponseDef(String queryResponseDef)
Builds a
ObjectResponse from a part of a GraphQL query. |
Builder |
withSubObject(ObjectResponse subobjetResponseDef)
Adds a non scalar field (a sub-object), to the
ObjectResponse we are building. |
public Builder(Class<?> owningClass, String fieldName) throws GraphQLRequestPreparationException
owningClass - The class that contains this fieldfieldName - The field for which we must build an ObjectResponseGraphQLRequestPreparationExceptionpublic Builder(Class<?> owningClass, String fieldName, String fieldAlias) throws GraphQLRequestPreparationException
owningClass - The class that contains this fieldfieldName - The field for which we must build an ObjectResponsefieldAlias - Its optional alias (may be null)GraphQLRequestPreparationExceptionpublic Builder withField(String fieldName) throws GraphQLRequestPreparationException
ObjectResponse we are buildingfieldName - NullPointerException - If the fieldName is nullGraphQLRequestPreparationException - If the fieldName or the fieldAlias is not validpublic Builder withField(String fieldName, String alias) throws GraphQLRequestPreparationException
ObjectResponse we are buildingfieldName - alias - NullPointerException - If the fieldName is nullGraphQLRequestPreparationException - If the fieldName or the fieldAlias is not valid@Deprecated public Builder withInputParameter(InputParameter inputParameter)
InputParameter to the current Object Response definition.inputParameter - Builderpublic Builder withInputParameterHardCoded(String name, Object value)
InputParameter to the current Object Response definition.name - name of the field parameter, as defined in the GraphQL schemavalue - The value to be sent to the server. If a String, it will be surroundered by double quotes, to be JSON
compatible. Otherwise, the toString() method is called to write the result in the GraphQL query.Builderpublic Builder withInputParameter(String name, String bindParameterName, boolean mandatory) throws GraphQLRequestPreparationException
InputParameter to the current Object Response definition.name - name of the field parameter, as defined in the GraphQL schemabindParameterName - The name of the parameter, as it will be provided later for the request execution: it's up to the
client application to provide (or not) a value associated with this parameterName.mandatory - true if this parameter must be provided for request execution. If mandatory is true, and no value is
provided for request execution, a GraphQLRequestExecutionException exception will be thrown,
instead of sending the request to the GraphQL server. Of course, parameter that are mandatory in the
GraphQL schema should be declared as mandatory here. But, depending on your client use case, you may
declare other parameter to be mandatory.BuilderGraphQLRequestPreparationExceptionpublic Builder withInputParameters(List<InputParameter> inputParameters)
InputParameters to the current Object Response definition.inputParameters - Builderpublic Builder withSubObject(ObjectResponse subobjetResponseDef) throws GraphQLRequestPreparationException
ObjectResponse we are building. The given objectResponse
contains the field name and its optional alias.subobjetResponseDef - The ObjectResponse for this sub-objectNullPointerException - If the fieldName is nullGraphQLRequestPreparationException - If the subobjetResponseDef can't be added. For instance: the fieldName or the fieldAlias is not
valid, or if the field of this subobjetResponseDef doesn't exist in the current owningClass...public ObjectResponse build() throws GraphQLRequestPreparationException
ObjectResponse. If no field (either scalar or suboject) has been added, then all scalar
fields are added.GraphQLRequestPreparationExceptionpublic Builder withQueryResponseDef(String queryResponseDef) throws GraphQLRequestPreparationException
ObjectResponse from a part of a GraphQL query. This part define what's expected as a response
for the field of the current ObjectResponse for this builder.queryResponseDef - A part of a response, for instance (for the hero query of the Star Wars GraphQL schema): "{ id name
friends{name}}"episode - GraphQLRequestPreparationExceptionCopyright © 2020. All rights reserved.