Mark-Lasfar commited on
Commit
c6ec071
ยท
1 Parent(s): 6eca6cc

Add GraphQL

Browse files
Files changed (1) hide show
  1. graphql/resolvers.js +15 -0
graphql/resolvers.js CHANGED
@@ -396,6 +396,21 @@ const resolvers = {
396
  if (typeof parent.sectionOrder === 'object') return Object.values(parent.sectionOrder);
397
  return [];
398
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
 
400
  // โœ… ุงู„ุญู‚ูˆู„ ุงู„ู„ูŠ ู…ูุฑูˆุถ ุชูƒูˆู† Objects
401
  sectionNames: (parent) => parent.sectionNames || {},
 
396
  if (typeof parent.sectionOrder === 'object') return Object.values(parent.sectionOrder);
397
  return [];
398
  },
399
+
400
+ hasStory: async (parent, args, context) => {
401
+ // ู„ูˆ ุงู„ู€ Profile ุฌุงูŠ ู…ู† UserุŒ ุงุณุชุฎุฏู… ุงู„ู€ userId
402
+ const userId = parent._id || parent.userId;
403
+ if (!userId) return false;
404
+ try {
405
+ const count = await Story.countDocuments({
406
+ userId: userId,
407
+ expiresAt: { $gt: new Date() }
408
+ });
409
+ return count > 0;
410
+ } catch (error) {
411
+ return false;
412
+ }
413
+ },
414
 
415
  // โœ… ุงู„ุญู‚ูˆู„ ุงู„ู„ูŠ ู…ูุฑูˆุถ ุชูƒูˆู† Objects
416
  sectionNames: (parent) => parent.sectionNames || {},