@@ -123,71 +123,19 @@ async def resolve_user_following(user: dict, _info: Any, limit: int = 10) -> lis
123123 return [USERS [str (fid )] for fid in following_ids if str (fid ) in USERS ]
124124
125125
126- # Field resolvers for scalar fields (still async to test async path)
127- async def resolve_id ( obj : dict , _info : Any ) -> str :
128- return obj [ "id" ]
126+ # Note: Scalar fields use the default resolver (dict key access) which is sync.
127+ # Only relationship fields (author, posts, comments, followers, following) have
128+ # explicit async resolvers to simulate real-world data fetching patterns.
129129
130130
131- async def resolve_username (obj : dict , _info : Any ) -> str :
132- return obj ["username" ]
133-
134-
135- async def resolve_email (obj : dict , _info : Any ) -> str :
136- return obj ["email" ]
137-
138-
139- async def resolve_display_name (obj : dict , _info : Any ) -> str :
140- return obj ["displayName" ]
141-
142-
143- async def resolve_bio (obj : dict , _info : Any ) -> str :
144- return obj ["bio" ]
145-
146-
147- async def resolve_follower_count (obj : dict , _info : Any ) -> int :
148- return obj ["followerCount" ]
149-
150-
151- async def resolve_following_count (obj : dict , _info : Any ) -> int :
152- return obj ["followingCount" ]
153-
154-
155- async def resolve_title (obj : dict , _info : Any ) -> str :
156- return obj ["title" ]
157-
158-
159- async def resolve_content (obj : dict , _info : Any ) -> str :
160- return obj ["content" ]
161-
162-
163- async def resolve_text (obj : dict , _info : Any ) -> str :
164- return obj ["text" ]
165-
166-
167- async def resolve_like_count (obj : dict , _info : Any ) -> int :
168- return obj ["likeCount" ]
169-
170-
171- async def resolve_comment_count (obj : dict , _info : Any ) -> int :
172- return obj ["commentCount" ]
173-
174-
175- async def resolve_created_at (obj : dict , _info : Any ) -> str :
176- return obj ["createdAt" ]
177-
178-
179- async def resolve_updated_at (obj : dict , _info : Any ) -> str :
180- return obj .get ("updatedAt" , obj ["createdAt" ])
181-
182-
183- # Build schema with explicit async resolvers
131+ # Build schema - scalar fields use default resolver, only relationships are async
184132CommentType : GraphQLObjectType = GraphQLObjectType (
185133 name = "Comment" ,
186134 fields = lambda : {
187- "id" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_id ),
188- "text" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_text ),
189- "likeCount" : GraphQLField (GraphQLNonNull (GraphQLInt ), resolve = resolve_like_count ),
190- "createdAt" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_created_at ),
135+ "id" : GraphQLField (GraphQLNonNull (GraphQLString )),
136+ "text" : GraphQLField (GraphQLNonNull (GraphQLString )),
137+ "likeCount" : GraphQLField (GraphQLNonNull (GraphQLInt )),
138+ "createdAt" : GraphQLField (GraphQLNonNull (GraphQLString )),
191139 "author" : GraphQLField (UserType , resolve = resolve_comment_author ),
192140 "post" : GraphQLField (PostType , resolve = resolve_comment_post ),
193141 },
@@ -196,13 +144,13 @@ async def resolve_updated_at(obj: dict, _info: Any) -> str:
196144PostType : GraphQLObjectType = GraphQLObjectType (
197145 name = "Post" ,
198146 fields = lambda : {
199- "id" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_id ),
200- "title" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_title ),
201- "content" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_content ),
202- "likeCount" : GraphQLField (GraphQLNonNull (GraphQLInt ), resolve = resolve_like_count ),
203- "commentCount" : GraphQLField (GraphQLNonNull (GraphQLInt ), resolve = resolve_comment_count ),
204- "createdAt" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_created_at ),
205- "updatedAt" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_updated_at ),
147+ "id" : GraphQLField (GraphQLNonNull (GraphQLString )),
148+ "title" : GraphQLField (GraphQLNonNull (GraphQLString )),
149+ "content" : GraphQLField (GraphQLNonNull (GraphQLString )),
150+ "likeCount" : GraphQLField (GraphQLNonNull (GraphQLInt )),
151+ "commentCount" : GraphQLField (GraphQLNonNull (GraphQLInt )),
152+ "createdAt" : GraphQLField (GraphQLNonNull (GraphQLString )),
153+ "updatedAt" : GraphQLField (GraphQLNonNull (GraphQLString )),
206154 "author" : GraphQLField (UserType , resolve = resolve_post_author ),
207155 "comments" : GraphQLField (
208156 GraphQLNonNull (GraphQLList (GraphQLNonNull (CommentType ))),
@@ -215,14 +163,14 @@ async def resolve_updated_at(obj: dict, _info: Any) -> str:
215163UserType : GraphQLObjectType = GraphQLObjectType (
216164 name = "User" ,
217165 fields = lambda : {
218- "id" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_id ),
219- "username" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_username ),
220- "email" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_email ),
221- "displayName" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_display_name ),
222- "bio" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_bio ),
223- "followerCount" : GraphQLField (GraphQLNonNull (GraphQLInt ), resolve = resolve_follower_count ),
224- "followingCount" : GraphQLField (GraphQLNonNull (GraphQLInt ), resolve = resolve_following_count ),
225- "createdAt" : GraphQLField (GraphQLNonNull (GraphQLString ), resolve = resolve_created_at ),
166+ "id" : GraphQLField (GraphQLNonNull (GraphQLString )),
167+ "username" : GraphQLField (GraphQLNonNull (GraphQLString )),
168+ "email" : GraphQLField (GraphQLNonNull (GraphQLString )),
169+ "displayName" : GraphQLField (GraphQLNonNull (GraphQLString )),
170+ "bio" : GraphQLField (GraphQLNonNull (GraphQLString )),
171+ "followerCount" : GraphQLField (GraphQLNonNull (GraphQLInt )),
172+ "followingCount" : GraphQLField (GraphQLNonNull (GraphQLInt )),
173+ "createdAt" : GraphQLField (GraphQLNonNull (GraphQLString )),
226174 "posts" : GraphQLField (
227175 GraphQLNonNull (GraphQLList (GraphQLNonNull (PostType ))),
228176 args = {"limit" : GraphQLArgument (GraphQLInt , default_value = 10 )},
0 commit comments