From cf020f8f3e445c2eeea2fbaa0247207710a278ef Mon Sep 17 00:00:00 2001 From: Tony Rewin Date: Thu, 2 Dec 2021 16:06:22 +0300 Subject: [PATCH] update comment schema and debug resolvers --- resolvers/zine.py | 9 ++++++--- schema.graphql | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/resolvers/zine.py b/resolvers/zine.py index f30ca203..449ae380 100644 --- a/resolvers/zine.py +++ b/resolvers/zine.py @@ -14,6 +14,8 @@ from datetime import datetime, timedelta from pathlib import Path from sqlalchemy import select, func, desc, and_ from sqlalchemy.orm import selectinload +import pprint + class GitTask: @@ -350,9 +352,10 @@ async def view_shout(_, info, shout_id): @query.field("getShoutBySlug") async def get_shout_by_slug(_, info, slug): - slug_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections] - slug_fields = set(["authors", "comments", "topics"]).intersection(slug_fields) - select_options = [selectinload(getattr(Shout, field)) for field in slug_fields] + all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections] + pprint(all_fields) + selected_fields = set(["authors", "comments", "topics"]).intersection(all_fields) + select_options = [selectinload(getattr(Shout, field)) for field in selected_fields] with local_session() as session: shout = session.query(Shout).\ diff --git a/schema.graphql b/schema.graphql index e22d62b0..b4b339d8 100644 --- a/schema.graphql +++ b/schema.graphql @@ -247,7 +247,7 @@ type Message { type Comment { id: Int! - author: Int! + author: User! body: String! replyTo: Int createdAt: DateTime!