Skip to content

Models

Definition for main data models used in this library.

EdgeQLOperationType (IntEnum)

Enumeration for operation types for queries.

Source code in edgeql_queries/models.py
class EdgeQLOperationType(IntEnum):
    """Enumeration for operation types for queries."""

    #: type for operation that definetly returns a single object.
    required_single_return = auto()

    #: type for operation that optionally returns a single object.
    single_return = auto()

    #: type for operation that returns a common set of object.
    set_return = auto()

    #: type for operation that returns nothing.
    execute = auto()

Query dataclass

Parsed query.

Source code in edgeql_queries/models.py
@dataclass(frozen=True)
class Query:
    """Parsed query."""

    #: name of parsed query.
    name: str

    #: query operation type.
    operation_type: EdgeQLOperationType

    #: EdgeQL query that should be executed.
    edgeql: str

    def __str__(self) -> str:
        """Return string representation of query.

        Returns:
            String representation of query that is its name.
        """
        return self.name

    def __repr__(self) -> str:
        """Return raw string representation of query.

        Returns:
            Raw string representation of query that contains all fields.
        """
        return "Query(name: {0!r}, operation_type: {1}, edgeql: {2!r})".format(
            self.name,
            self.operation_type.name,
            self.edgeql,
        )

__repr__(self) special

Return raw string representation of query.

Returns:

Type Description
str

Raw string representation of query that contains all fields.

Source code in edgeql_queries/models.py
def __repr__(self) -> str:
    """Return raw string representation of query.

    Returns:
        Raw string representation of query that contains all fields.
    """
    return "Query(name: {0!r}, operation_type: {1}, edgeql: {2!r})".format(
        self.name,
        self.operation_type.name,
        self.edgeql,
    )

__str__(self) special

Return string representation of query.

Returns:

Type Description
str

String representation of query that is its name.

Source code in edgeql_queries/models.py
def __str__(self) -> str:
    """Return string representation of query.

    Returns:
        String representation of query that is its name.
    """
    return self.name