@Component public class GraphqlClientUtils extends Object
| Constructor and Description |
|---|
GraphqlClientUtils() |
| Modifier and Type | Method and Description |
|---|---|
Class<?> |
checkFieldOfGraphQLType(String name,
Boolean shouldBeScalar,
Class<?> owningClass)
Check if the given field is owned by the class of this
ObjectResponse. |
Class<?> |
checkIsScalar(Field field,
Boolean shouldBeScalar)
This method checks whether the given field (as an attribute) of the given class is a GraphQL scalar, or not,
depending on shouldBeScalar.
|
Class<?> |
checkIsScalar(String fieldName,
Method method,
Boolean shouldBeScalar)
This method checks whether the given field (as a method: getter, query...) of the given class is a GraphQL
scalar, or not, depending on shouldBeScalar.
|
void |
checkName(String graphqlIdentifier)
Checks that the given GraphQL name is valid.
|
Map<String,Object> |
generatesBindVariableValuesMap(Object[] paramsAndValues)
This method retrieves the couple of name and values given in these parameters, stores them in a map where the key
is the param name, and the value is the value of the
Map. |
Class<?> |
getGraphQLType(AccessibleObject fieldOrMethod)
Returns the Class indicated as the value for the graphqlType attribute of the GraphQLScalar or GraphQLNonScalar
annotation
|
boolean |
isScalar(AccessibleObject fieldOrMethod)
Indicates whether the given class is a scalar or not
|
public void checkName(String graphqlIdentifier) throws GraphQLRequestPreparationException
graphqlIdentifier - NullPointerException - If name is nullGraphQLRequestPreparationException - If the given graphqlIdentifier is not a valid identifierpublic Class<?> checkIsScalar(Field field, Boolean shouldBeScalar) throws GraphQLRequestPreparationException
field - The field whose type should be (or not) a scalarshouldBeScalar - if true, this method checks that field's type is a scalar (if false, checks that it is not a scalar)GraphQLRequestPreparationExceptionpublic Class<?> checkIsScalar(String fieldName, Method method, Boolean shouldBeScalar) throws GraphQLRequestPreparationException
fieldName - the name of the field represented by the given method.method - The method whose return should be (or not) a scalar. This method can be a setter, a getter (in which
case its name is different from the fieldName), or a query/mutation/subscription (in which case its
name is the fieldName)shouldBeScalar - if true, this method checks that method return type is a scalar (if false, checks that it is not a
scalar)GraphQLRequestPreparationExceptionpublic boolean isScalar(AccessibleObject fieldOrMethod) throws GraphQLRequestPreparationException
fieldOrMethod - GraphQLRequestPreparationExceptionpublic Class<?> getGraphQLType(AccessibleObject fieldOrMethod) throws GraphQLRequestPreparationException
fieldOrMethod - GraphQLRequestPreparationExceptionpublic Class<?> checkFieldOfGraphQLType(String name, Boolean shouldBeScalar, Class<?> owningClass) throws GraphQLRequestPreparationException
ObjectResponse. This method returns the class for
this field.name - The name of the field we want to checkshouldBeScalar - if true: also checks that the field is a scalar (throws a GraphQLRequestPreparationException if not).
If false: also checks that the field is not a scalar (throws a GraphQLRequestPreparationException if
not). If null: no check whether the field is a scalar or notowningClass - The class in which will search for name as a GraphQL fieldNullPointerException - if name is nullGraphQLRequestPreparationException - if the check is KOpublic Map<String,Object> generatesBindVariableValuesMap(Object[] paramsAndValues) throws GraphQLRequestExecutionException, ClassCastException
Map.paramsAndValues - A series of name and values : (paramName1, paramValue1, paramName2, paramValue2...). So there must be
an even number of items in this array. Empty arrays are allowed (that is no parameter name and
value).GraphQLRequestExecutionException - When a non-even number of parameters is sent to this methodClassCastException - When a parameter name is not a StringCopyright © 2020. All rights reserved.