Repository: PalisadoesFoundation/talawa (language: dart)

Issue:
Explore Events page is failing to fetch Events.
**Describe the bug**
**Explore Events page not working properly.**
The `Explore Events page` fails to retrieve events from the server, consistently displaying an `empty list message` on the screen despite the` existence of events` in the database.

**To Reproduce**
Steps to reproduce the behavior:

1. Navigate to Explore Events page.
2. Refresh the page / Create an event.

**Expected behavior**
The `created events` / `existing events from database` should be shown on screen in a vertical scrolling fashion.

**Actual behavior**
`empty list` message is being shown always, despite the events present in the database.

**Screenshots**
**Actual**
![Screenshot_20240106-041638](https://github.com/PalisadoesFoundation/talawa/assets/120930148/cbae99e2-06de-401f-96e5-1d98c914645f)

**Expected**
![Screenshot_20240106-041619](https://github.com/PalisadoesFoundation/talawa/assets/120930148/555a838c-c0ea-41a2-9518-33b8af78647b)

**Additional details**
1. The Details of the Event are also not properly being fetched into the `EventCard` and `Event Page`.

**Potential internship candidates**
Please read this if you are planning to apply for a Palisadoes Foundation internship https://github.com/PalisadoesFoundation/talawa/issues/359



Discussion hints:
@noman2002 @Cioppolo14 @Kevoniat please assign me this issue, I would like to work on this.
https://github.com/PalisadoesFoundation/talawa/issues/2195

This issue already exists and someone is working on it, the reason why events are not getting fetched because of same problem why you cannot create an event which is related to firebase. Right when app initialise if you check debug console you could see graphql exception related to this.
@Dante291 Please understand This issue is different from the issue you have mentioned.
1. The issue you have mentioned solely  focuses on Failure of creating a new event.
2. This issue focuses on failure of fetching the events existing in the database. 
3. Try creating an Event through admin panel and then try to find it in explore events page. It's not possible to see the created event in the explore events page
But it's visible in admin panel.
@Azad99-9 This is the exception you get when you try to make a new event 

![image](https://github.com/PalisadoesFoundation/talawa/assets/103507835/d8c5b9dd-b8e7-4fb2-9690-b6aa97925f99)

and this is the exception when you fetch events 

![image](https://github.com/PalisadoesFoundation/talawa/assets/103507835/72612d25-4658-4cfc-818f-0688e6f8dee1)

which are basically same, this exception is occurring due to some error related to firebase. 

You could work on this though, this will resolve both issues ig.


> @Dante291 Please understand This issue is different from the issue you have mentioned.
> 
> 1. The issue you have mentioned solely  focuses on Failure of creating a new event.
> 2. This issue focuses on failure of fetching the events existing in the database.
> 3. Try creating an Event through admin panel and then try to find it in explore events page. It's not possible to see the created event in the explore events page
>    But it's visible in admin panel.

Yeah, event is getting created successfully but the main problem is with fetching ig so basically https://github.com/PalisadoesFoundation/talawa/issues/2195 this issue should be about fetching of events is giving exception due to firebase?? maybe this exception is occurring because we are using same query to fetch events just after making a new event (which is created successfully). 
> @Dante291 I am working with @Abhisheksainii on this.

I figured out the root cause of the problem by some lil debugging 

![Screenshot 2024-01-06 130842](https://github.com/PalisadoesFoundation/talawa/assets/103507835/21d03654-33fc-4226-b9e7-b63178e31191)

![Screenshot 2024-01-06 130820](https://github.com/PalisadoesFoundation/talawa/assets/103507835/52c4a2ca-a791-4bb2-a930-9ae7d6c3e4da)


I think the problem is with fetchOrgEvents query (it is stated as mutation, it should be query not mutation) which may be related to backend side ig.
@Dante291 nice work bro. This will surely help the backend developer to resolve the issue
> @Dante291 nice work bro. This will surely help the backend developer to resolve the issue

No ig the issue is with fetchOrgEvents  query only because in admin portal events are getting fetched successfully, so it might not be a problem related to backend but with the query only, you guys could further work on this to find the main cause and if its the query do update it and ig that will fix the problem.
@Dante291 Yes you are right I solved an issue earlier in which comments were not visible, initially I thought it was backend issue but then I realized  I was able to fetch the comments by just modifying the query. Events can be fetched in a similar way.

Pull request: fixed fetch events bug
<!--
This section can be deleted after reading.

We employ the following branching strategy to simplify the development process and to ensure that only stable code is pushed to the `master` branch:

- `develop`: For unstable code: New features and bug fixes.
- `master`: Where the stable production ready code lies. Only security related bugs.

NOTE!!!

ONLY SUBMIT PRS AGAINST OUR `DEVELOP` BRANCH. THE DEFAULT IS `MAIN`, SO YOU WILL HAVE TO MODIFY THIS BEFORE SUBMITTING YOUR PR FOR REVIEW. PRS MADE AGAINST `MAIN` WILL BE CLOSED.
-->

<!--
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request.
-->

**What kind of change does this PR introduce?**

This PR fixes the event fetching bug in explore events page.

**Issue Number:**

Fixes #2307 

**Did you add tests for your changes?**



**Snapshots/Videos:**

![Screenshot_20240106-041619](https://github.com/PalisadoesFoundation/talawa/assets/120930148/2d2e4614-a5b2-45d2-91c9-253685bdf3e6)


**If relevant, did you update the documentation?**

<!--Add link to Talawa-Docs.-->

**Summary**

Removed a field name `registrants` from the query which is not actually defined for the Collection `Event` in the `database`.

**Does this PR introduce a breaking change?**

No

**Other information**

<!--Add extra information about this PR here-->

**Have you read the [contributing guide](https://github.com/PalisadoesFoundation/talawa/blob/master/CONTRIBUTING.md)?**
Yes

Test command: nan

Fix patch:
diff --git a/lib/utils/event_queries.dart b/lib/utils/event_queries.dart
index 23b06458b5..14c9e82e52 100644
--- a/lib/utils/event_queries.dart
+++ b/lib/utils/event_queries.dart
@@ -1,9 +1,15 @@
-// ignore_for_file: talawa_api_doc
-// ignore_for_file: talawa_good_doc_comments
-
 ///This class creates queries related to the events.
 class EventQueries {
-  //Returns a query to fetch an organization's events
+  /// Fetches events by organization ID.
+  ///
+  /// **params**:
+  /// * `orgId`: The ID of the organization to fetch events for.
+  ///
+  /// **returns**:
+  /// * `String`: Returns a GraphQL query string to fetch events associated with the specified organization ID.
+  ///
+  /// This function generates a GraphQL query string to retrieve events
+  /// based on the provided organization ID.
   String fetchOrgEvents(String orgId) {
     return """
       query {
@@ -34,17 +40,21 @@ class EventQueries {
             firstName
             lastName
           }
-          registrants {
-            user {
-              _id
-            }
-          }
         }
       }
     """;
   }
 
-  //returns a query to get the registrants of a particular event.
+  /// Fetches registrants by event ID.
+  ///
+  /// **params**:
+  /// * `eventId`: The ID of the event to fetch registrants for.
+  ///
+  /// **returns**:
+  /// * `String`: Returns a GraphQL query string to retrieve registrants associated with the specified event ID.
+  ///
+  /// This function generates a GraphQL query string to fetch registrants
+  /// based on the provided event ID.
   String registrantsByEvent(String eventId) {
     return '''
       query {
@@ -58,7 +68,15 @@ class EventQueries {
     ''';
   }
 
-  //returns a query to add an event.
+  /// Creates a GraphQL mutation for adding an event.
+  ///
+  /// **params**:
+  ///   None
+  ///
+  /// **returns**:
+  /// * `String`: Returns a GraphQL mutation string to create an event.
+  ///
+  /// This function generates a GraphQL mutation string for creating an event.
   String addEvent() {
     return """
      mutation createEvent( \$organizationId: ID!,
@@ -98,7 +116,15 @@ class EventQueries {
   """;
   }
 
-  //returns a query to register for an event
+  /// Creates a GraphQL mutation for registering for an event.
+  ///
+  /// **params**:
+  ///   None
+  ///
+  /// **returns**:
+  /// * `String`: Returns a GraphQL mutation string to register for the specified event.
+  ///
+  /// This function generates a GraphQL mutation string for registering an individual for an event.
   String registerForEvent() {
     return """
      mutation registerForEvent(\$eventId: ID!) { 
@@ -112,7 +138,16 @@ class EventQueries {
   """;
   }
 
-  //returns a query to delete an event
+  /// Creates a GraphQL mutation for deleting an event.
+  ///
+  /// **params**:
+  /// * `id`: The ID of the event to delete.
+  ///
+  /// **returns**:
+  /// * `String`: Returns a GraphQL mutation string to delete the specified event.
+  ///
+  /// This function generates a GraphQL mutation string for removing/deleting an event
+  /// based on the provided event ID.
   String deleteEvent(String id) {
     return """
       mutation {
@@ -125,7 +160,19 @@ class EventQueries {
     """;
   }
 
-  //returns a query to update an event
+  /// Creates a GraphQL mutation for updating an event.
+  ///
+  /// **params**:
+  /// * `eventId`: The ID of the event to update.
+  ///
+  /// **returns**:
+  /// * `String`: Returns a GraphQL mutation string to update the specified event.
+  ///
+  /// This function generates a GraphQL mutation string for updating an event
+  /// based on the provided parameters. It takes the event ID along with updated
+  /// details.
+  /// The mutation updates the event details and returns the ID, title, and description
+  /// of the updated event.
   String updateEvent({
     eventId,
   }) {


Test patch:
diff --git a/test/utils/event_queries_test.dart b/test/utils/event_queries_test.dart
index a3d03a86f4..cb9fe23fe9 100644
--- a/test/utils/event_queries_test.dart
+++ b/test/utils/event_queries_test.dart
@@ -1,6 +1,3 @@
-// ignore_for_file: talawa_api_doc
-// ignore_for_file: talawa_good_doc_comments
-
 import 'package:flutter_test/flutter_test.dart';
 import 'package:talawa/utils/event_queries.dart';
 
@@ -36,11 +33,6 @@ void main() {
             firstName
             lastName
           }
-          registrants {
-            user {
-              _id
-            }
-          }
         }
       }
     """;