Skip to content

Commit

Permalink
feat: make it run as federation
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Sep 28, 2024
1 parent 3fec38d commit 2bd342b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
24 changes: 8 additions & 16 deletions gql/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from pathlib import Path
from typing import Any, Iterator

from ariadne import ObjectType, QueryType, gql, make_executable_schema
from ariadne import ObjectType, QueryType, gql
from ariadne.asgi import GraphQL
from ariadne.contrib.federation import make_federated_schema
from sqlalchemy import select
from starlette.applications import Starlette
from starlette.routing import Mount

from chii.compat import phpseralize
from chii.config import config
from chii.const import CollectionType
from chii.db import sa
from chii.db.tables import ChiiTimeline, ChiiTimeline_column_cat, ChiiTimeline_column_id
Expand Down Expand Up @@ -69,18 +69,10 @@ async def timeline_collection(*_: Any) -> list[CollectTimeline]:
gql_collect_timeline = ObjectType("CollectTimeline")

# Create executable GraphQL schema
schema = make_executable_schema(type_defs, gql_query, gql_collect_timeline)
schema = make_federated_schema(type_defs, gql_query, gql_collect_timeline)

app = Starlette(
debug=True,
routes=[
Mount(
"/graphql",
GraphQL(
schema,
debug=True,
validation_rules=[depth_limit_validator(max_depth=5)],
),
),
],
app = GraphQL(
schema,
debug=config.debug,
validation_rules=[depth_limit_validator(max_depth=5)],
)
2 changes: 1 addition & 1 deletion gql/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Query {
extend type Query {
timeline_collection:[CollectTimeline!]!
}

Expand Down

0 comments on commit 2bd342b

Please sign in to comment.