Skip to content

Commit

Permalink
Move inputs to query file
Browse files Browse the repository at this point in the history
  • Loading branch information
shangyian committed Jan 10, 2025
1 parent c45a792 commit 7385ac3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 52 deletions.
52 changes: 47 additions & 5 deletions datajunction-server/datajunction_server/api/graphql/queries/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,56 @@
import strawberry
from strawberry.types import Info

from datajunction_server.api.graphql.scalars.sql import (
CubeDefinition,
EngineSettings,
GeneratedSQL,
)
from datajunction_server.api.graphql.scalars.sql import GeneratedSQL
from datajunction_server.construction.build_v2 import get_measures_query


@strawberry.input
class CubeDefinition: # pylint: disable=too-few-public-methods
"""
The cube definition for the query
"""

metrics: Annotated[
list[str],
strawberry.argument(
description="A list of metric node names",
),
] = None # type: ignore
dimensions: Annotated[
list[str] | None,
strawberry.argument(
description="A list of dimension attribute names",
),
] = None
filters: Annotated[
list[str] | None,
strawberry.argument(
description="A list of filter SQL clauses",
),
] = None
orderby: Annotated[
list[str] | None,
strawberry.argument(
description="A list of order by clauses",
),
] = None


@strawberry.input
class EngineSettings: # pylint: disable=too-few-public-methods
"""
The engine settings for the query
"""

name: str = strawberry.field(
description="The name of the engine used by the generated SQL",
)
version: str | None = strawberry.field(
description="The version of the engine used by the generated SQL",
)


async def measures_sql(
cube: CubeDefinition,
engine: Optional[EngineSettings] = None,
Expand Down
47 changes: 0 additions & 47 deletions datajunction-server/datajunction_server/api/graphql/scalars/sql.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""SQL-related scalars."""
from functools import cached_property
from typing import Annotated

import strawberry
from strawberry.types import Info
Expand All @@ -20,52 +19,6 @@
QueryBuildType = strawberry.enum(QueryBuildType_)


@strawberry.input
class CubeDefinition: # pylint: disable=too-few-public-methods
"""
The cube definition for the query
"""

metrics: Annotated[
list[str],
strawberry.argument(
description="A list of metric node names",
),
] = None # type: ignore
dimensions: Annotated[
list[str] | None,
strawberry.argument(
description="A list of dimension attribute names",
),
] = None
filters: Annotated[
list[str] | None,
strawberry.argument(
description="A list of filter SQL clauses",
),
] = None
orderby: Annotated[
list[str] | None,
strawberry.argument(
description="A list of order by clauses",
),
] = None


@strawberry.input
class EngineSettings: # pylint: disable=too-few-public-methods
"""
The engine settings for the query
"""

name: str = strawberry.field(
description="The name of the engine used by the generated SQL",
)
version: str | None = strawberry.field(
description="The version of the engine used by the generated SQL",
)


@strawberry.type
class SemanticEntity:
"""
Expand Down

0 comments on commit 7385ac3

Please sign in to comment.