Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed fetch events bug #2308

Merged
merged 4 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading