Class 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 Detail

      • of

        public static OperationModel of​(org.jboss.jandex.MethodInfo method)
        Creates and returns a new OperationModel instance based on the provided Jandex MethodInfo.
        Parameters:
        method - The Jandex MethodInfo representing the GraphQL operation method.
        Returns:
        A new OperationModel instance.
      • fields

        public String fields​(TypeModel type)
        Generates GraphQL query fields for the specified TypeModel.
        Parameters:
        type - The TypeModel for 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 specified TypeModel with recursion checking.
        Parameters:
        type - The TypeModel for 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 provided FieldModel.
        Parameters:
        field - The FieldModel representing the field.
        Returns:
        The GraphQL representation of the field.
      • declare

        public String declare​(ParameterModel parameter)
        Declares a GraphQL parameter for the specified ParameterModel.
        Parameters:
        parameter - The ParameterModel for 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 specified ParameterModel.
        Parameters:
        parameter - The ParameterModel for 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 OperationType of the GraphQL operation.
      • queryName

        public Optional<String> queryName()
        Gets the name of the GraphQL operation, considering any Query or Name annotations.
        Returns:
        An optional containing the operation name if specified, otherwise empty.
      • mutationName

        public Optional<String> mutationName()
        Gets the name of the GraphQL mutation, considering any Mutation annotation.
        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: NamedElement
        Gets the name of the NamedElement, considering any Name annotation if present.
        Specified by:
        getName in interface NamedElement
        Returns:
        The field name.
      • getRawName

        public String getRawName()
        Description copied from interface: NamedElement
        Gets the raw (original) name of the NamedElement.
        Specified by:
        getRawName in interface NamedElement
        Returns:
        The raw field name.
      • getDirectiveLocation

        public String getDirectiveLocation()
        Description copied from interface: NamedElement
        Gets the location of directives associated with this NamedElement.
        Specified by:
        getDirectiveLocation in interface NamedElement
        Returns:
        The directive location
      • hasDirectives

        public boolean hasDirectives()
        Description copied from interface: NamedElement
        Checks if the NamedElement has associated directives.
        Specified by:
        hasDirectives in interface NamedElement
        Returns:
        true if the NamedElement has directives, otherwise false.
      • 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 TypeModel representing the return type.
      • hasValueParameters

        public boolean hasValueParameters()
        Checks if the GraphQL operation has value parameters.
        Returns:
        true if the operation has value parameters, otherwise false.
      • hasRootParameters

        public boolean hasRootParameters()
        Checks if the GraphQL operation has root-level parameters.
        Returns:
        true if the operation has root parameters, otherwise false.
      • isSingle

        public boolean isSingle()
        Checks if the GraphQL operation returns a single result (one GraphQL operation).
        Returns:
        true if the operation returns a single result, otherwise false.
      • getMethodKey

        public MethodKey getMethodKey()
        Gets the key for identifying the GraphQL operation method.
        Returns:
        The MethodKey representing 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.