Skip to content

Commit

Permalink
fixed fetch events bug (PalisadoesFoundation#2308)
Browse files Browse the repository at this point in the history
* fixed events fetching bug

* fixed failing tests

* added comments to event_queries

* fixed failing test
  • Loading branch information
Azad99-9 authored and palisadian committed Jan 10, 2024
1 parent 4c7c5b0 commit 9d54b2d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 22 deletions.
75 changes: 61 additions & 14 deletions lib/utils/event_queries.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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!,
Expand Down Expand Up @@ -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!) {
Expand All @@ -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 {
Expand All @@ -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,
}) {
Expand Down
8 changes: 0 additions & 8 deletions test/utils/event_queries_test.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -36,11 +33,6 @@ void main() {
firstName
lastName
}
registrants {
user {
_id
}
}
}
}
""";
Expand Down

0 comments on commit 9d54b2d

Please sign in to comment.