update comment schema and debug resolvers

This commit is contained in:
Tony Rewin 2021-12-02 16:06:22 +03:00
parent 1a4b7a6f0a
commit cf020f8f3e
2 changed files with 7 additions and 4 deletions

View File

@ -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).\

View File

@ -247,7 +247,7 @@ type Message {
type Comment {
id: Int!
author: Int!
author: User!
body: String!
replyTo: Int
createdAt: DateTime!