Class OperationModel
- java.lang.Object
-
- io.smallrye.graphql.client.model.helper.OperationModel
-
- All Implemented Interfaces:
NamedElement
public class OperationModel extends Object implements NamedElement
Represents a model for a GraphQL operation method, providing methods to generate GraphQL query fields, handle parameter bindings, and extract operation-related information.- Author:
- mskacelik
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringbind(ParameterModel parameter)Binds a GraphQL parameter for the specifiedParameterModel.Stringdeclare(ParameterModel parameter)Declares a GraphQL parameter for the specifiedParameterModel.Stringfield(FieldModel field)Generates the GraphQL representation of a field based on the providedFieldModel.Stringfields(TypeModel type)Generates GraphQL query fields for the specifiedTypeModel.StringgetDirectiveLocation()Gets the location of directives associated with this NamedElement.List<DirectiveInstance>getDirectives()Gets the list of directives associated with the NamedElement.MethodKeygetMethodKey()Gets the key for identifying the GraphQL operation method.StringgetName()Gets the name of the NamedElement, considering anyNameannotation if present.OperationTypegetOperationType()Gets the operation type of the GraphQL operation.StringgetOperationTypeAsString()Gets the string representation of the operation type (query, mutation, or subscription).StringgetRawName()Gets the raw (original) name of the NamedElement.TypeModelgetReturnType()Gets the return type of the GraphQL operation.booleanhasDirectives()Checks if the NamedElement has associated directives.booleanhasRootParameters()Checks if the GraphQL operation has root-level parameters.booleanhasValueParameters()Checks if the GraphQL operation has value parameters.booleanisSingle()Checks if the GraphQL operation returns a single result (one GraphQL operation).Optional<String>mutationName()Gets the name of the GraphQL mutation, considering anyMutationannotation.StringnestedExpressionPrefix()Retrieves the prefix for nested expressions in GraphQL queries.List<ParameterModel>nestedParameters(String path)Retrieves the list of parameters representing nested parameters for the GraphQL operation.static OperationModelof(org.jboss.jandex.MethodInfo method)Creates and returns a newOperationModelinstance based on the provided JandexMethodInfo.Optional<String>queryName()Gets the name of the GraphQL operation, considering anyQueryorNameannotations.StringrecursionCheckedFields(TypeModel type)Generates GraphQL query fields for the specifiedTypeModelwith recursion checking.List<ParameterModel>rootParameters()Retrieves the list of parameters representing the root-level parameters for the GraphQL operation.Optional<String>subscriptionName()Gets the name of the GraphQL subscription, considering any io.smallrye.graphql.api.Subscription annotation.List<ParameterModel>valueParameters()Retrieves the list of parameters representing the values for the GraphQL operation.
-
-
-
Method Detail
-
of
public static OperationModel of(org.jboss.jandex.MethodInfo method)
Creates and returns a newOperationModelinstance based on the provided JandexMethodInfo.- Parameters:
method- The JandexMethodInforepresenting the GraphQL operation method.- Returns:
- A new
OperationModelinstance.
-
fields
public String fields(TypeModel type)
Generates GraphQL query fields for the specifiedTypeModel.- Parameters:
type- TheTypeModelfor which to generate GraphQL query fields.- Returns:
- The generated GraphQL query fields.
- Throws:
IllegalStateException- If a field recursion is detected.
-
recursionCheckedFields
public String recursionCheckedFields(TypeModel type)
Generates GraphQL query fields for the specifiedTypeModelwith recursion checking.- Parameters:
type- TheTypeModelfor which to generate GraphQL query fields.- Returns:
- The generated GraphQL query fields.
-
field
public String field(FieldModel field)
Generates the GraphQL representation of a field based on the providedFieldModel.- Parameters:
field- TheFieldModelrepresenting the field.- Returns:
- The GraphQL representation of the field.
-
declare
public String declare(ParameterModel parameter)
Declares a GraphQL parameter for the specifiedParameterModel.- Parameters:
parameter- TheParameterModelfor which to declare the GraphQL parameter.- Returns:
- The GraphQL declaration of the parameter.
-
bind
public String bind(ParameterModel parameter)
Binds a GraphQL parameter for the specifiedParameterModel.- Parameters:
parameter- TheParameterModelfor which to bind the GraphQL parameter.- Returns:
- The GraphQL binding of the parameter.
-
nestedExpressionPrefix
public String nestedExpressionPrefix()
Retrieves the prefix for nested expressions in GraphQL queries.- Returns:
- The prefix for nested expressions.
-
getOperationType
public OperationType getOperationType()
Gets the operation type of the GraphQL operation.- Returns:
- The
OperationTypeof the GraphQL operation.
-
queryName
public Optional<String> queryName()
Gets the name of the GraphQL operation, considering anyQueryorNameannotations.- Returns:
- An optional containing the operation name if specified, otherwise empty.
-
mutationName
public Optional<String> mutationName()
Gets the name of the GraphQL mutation, considering anyMutationannotation.- Returns:
- An optional containing the mutation name if specified, otherwise empty.
-
subscriptionName
public Optional<String> subscriptionName()
Gets the name of the GraphQL subscription, considering any io.smallrye.graphql.api.Subscription annotation.- Returns:
- An optional containing the subscription name if specified, otherwise empty.
-
getName
public String getName()
Description copied from interface:NamedElementGets the name of the NamedElement, considering anyNameannotation if present.- Specified by:
getNamein interfaceNamedElement- Returns:
- The field name.
-
getRawName
public String getRawName()
Description copied from interface:NamedElementGets the raw (original) name of the NamedElement.- Specified by:
getRawNamein interfaceNamedElement- Returns:
- The raw field name.
-
getDirectiveLocation
public String getDirectiveLocation()
Description copied from interface:NamedElementGets the location of directives associated with this NamedElement.- Specified by:
getDirectiveLocationin interfaceNamedElement- Returns:
- The directive location
-
hasDirectives
public boolean hasDirectives()
Description copied from interface:NamedElementChecks if the NamedElement has associated directives.- Specified by:
hasDirectivesin interfaceNamedElement- Returns:
trueif the NamedElement has directives, otherwisefalse.
-
getDirectives
public List<DirectiveInstance> getDirectives()
Description copied from interface:NamedElementGets the list of directives associated with the NamedElement.- Specified by:
getDirectivesin interfaceNamedElement- Returns:
- The list of
DirectiveInstanceobjects.
-
valueParameters
public List<ParameterModel> valueParameters()
Retrieves the list of parameters representing the values for the GraphQL operation.- Returns:
- The list of value parameters.
-
rootParameters
public List<ParameterModel> rootParameters()
Retrieves the list of parameters representing the root-level parameters for the GraphQL operation.- Returns:
- The list of root parameters.
-
nestedParameters
public List<ParameterModel> nestedParameters(String path)
Retrieves the list of parameters representing nested parameters for the GraphQL operation.- Parameters:
path- The path for which nested parameters are retrieved.- Returns:
- The list of nested parameters.
-
getReturnType
public TypeModel getReturnType()
Gets the return type of the GraphQL operation.- Returns:
- The
TypeModelrepresenting the return type.
-
hasValueParameters
public boolean hasValueParameters()
Checks if the GraphQL operation has value parameters.- Returns:
trueif the operation has value parameters, otherwisefalse.
-
hasRootParameters
public boolean hasRootParameters()
Checks if the GraphQL operation has root-level parameters.- Returns:
trueif the operation has root parameters, otherwisefalse.
-
isSingle
public boolean isSingle()
Checks if the GraphQL operation returns a single result (one GraphQL operation).- Returns:
trueif the operation returns a single result, otherwisefalse.
-
getMethodKey
public MethodKey getMethodKey()
Gets the key for identifying the GraphQL operation method.- Returns:
- The
MethodKeyrepresenting the key for the operation method (name, parameters types).
-
getOperationTypeAsString
public String getOperationTypeAsString()
Gets the string representation of the operation type (query, mutation, or subscription).- Returns:
- The string representation of the operation type.
-
-