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)
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 validpublic Builder withInputParameter(InputParameter inputParameter)
InputParameter to the current Object Response definition.inputParameter - Builderpublic 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.