Mark-Lasfar commited on
Commit
d606181
·
1 Parent(s): b21014d

Add GraphQL

Browse files
Files changed (1) hide show
  1. graphql/resolvers.js +12 -7
graphql/resolvers.js CHANGED
@@ -263,15 +263,20 @@ const resolvers = {
263
  },
264
 
265
  hasStory: async (parent) => {
266
- // التحقق إذا كان المستخدم عنده Stories غير منتهية
267
- const now = new Date();
268
- const storyCount = await Story.countDocuments({
269
- userId: parent._id,
270
- expiresAt: { $gt: now }
271
- });
272
- return storyCount > 0;
 
 
 
 
273
  }
274
 
 
275
  },
276
  // ============================================
277
  // 🔹 COMMENT RESOLVERS - ✅ الحل النهائي
 
263
  },
264
 
265
  hasStory: async (parent) => {
266
+ try {
267
+ const now = new Date();
268
+ const storyCount = await Story.countDocuments({
269
+ userId: parent._id,
270
+ expiresAt: { $gt: now }
271
+ });
272
+ return storyCount > 0;
273
+ } catch (error) {
274
+ console.error('hasStory error:', error);
275
+ return false;
276
+ }
277
  }
278
 
279
+
280
  },
281
  // ============================================
282
  // 🔹 COMMENT RESOLVERS - ✅ الحل النهائي