Skip to content

Commit

Permalink
Add Version query to GraphQL schema
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Mar 21, 2024
1 parent 25b2814 commit abdb46d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/nextline_schedule/graphql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
sub = pwd / 'queries'
QUERY_AUTO_MODE = (sub / 'AutoMode.gql').read_text()
QUERY_SCHEDULER = (sub / 'Scheduler.gql').read_text()
QUERY_VERSION = (sub / 'Version.gql').read_text()

sub = pwd / 'subscriptions'
SUBSCRIBE_AUTO_MODE_STATE = (sub / 'ScheduleAutoModeState.gql').read_text()
5 changes: 5 additions & 0 deletions src/nextline_schedule/graphql/queries/Version.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query Version {
schedule {
version
}
}
4 changes: 4 additions & 0 deletions src/nextline_schedule/schema/query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import strawberry
from strawberry.types import Info

import nextline_schedule


def query_auto_mode_state(info: Info) -> str:
auto_mode = info.context["auto_mode"]
Expand Down Expand Up @@ -36,6 +38,8 @@ class QueryScheduler:

@strawberry.type
class QuerySchedule:
version: str = nextline_schedule.__version__

@strawberry.field
def auto_mode(self, info: Info) -> QueryAutoMode:
return QueryAutoMode()
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions tests/schema/queries/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import strawberry

import nextline_schedule
from nextline_schedule.graphql import QUERY_VERSION
from nextline_schedule.schema import Query


async def test_version():
schema = strawberry.Schema(query=Query)
resp = await schema.execute(QUERY_VERSION)
assert resp.data['schedule']['version'] == nextline_schedule.__version__

0 comments on commit abdb46d

Please sign in to comment.