Skip to content

Commit

Permalink
update field name and make resolvers nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
meetulr committed Jan 11, 2024
1 parent cd02629 commit dc7180e
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 135 deletions.
62 changes: 0 additions & 62 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@ directive @auth on FIELD_DEFINITION

directive @role(requires: UserType) on FIELD_DEFINITION

type ActionItem {
_id: ID!
assignedBy: User!
assignedTo: User!
assignmentDate: Date
category: Category!
completed: Boolean
completionDate: Date
createdAt: Date!
createdBy: User!
dueDate: Date
event: Event
postCompletionNotes: String
preCompletionNotes: String
updatedAt: Date!
}

type Address {
city: String
countryCode: CountryCode
Expand Down Expand Up @@ -67,16 +50,6 @@ type AuthData {
user: User!
}

type Category {
_id: ID!
category: String!
createdAt: Date!
createdBy: User!
disabled: Boolean!
org: Organization!
updatedAt: Date!
}

type CheckIn {
_id: ID!
allotedRoom: String
Expand Down Expand Up @@ -125,17 +98,6 @@ type ConnectionPageInfo {

scalar CountryCode

input CreateActionItemInput {
assignedTo: ID!
assignmentDate: Date
completed: Boolean
completionDate: Date
dueDate: Date
event: ID
postCompletionNotes: String
preCompletionNotes: String
}

input CreateUserTagInput {
name: String!
organizationId: ID!
Expand Down Expand Up @@ -231,7 +193,6 @@ interface Error {

type Event {
_id: ID!
actionItems: [ActionItem]
admins(adminId: ID): [User]
allDay: Boolean!
attendees: [User!]!
Expand Down Expand Up @@ -505,10 +466,8 @@ type Mutation {
blockUser(organizationId: ID!, userId: ID!): User!
cancelMembershipRequest(membershipRequestId: ID!): MembershipRequest!
checkIn(data: CheckInInput!): CheckIn!
createActionItem(categoryId: ID!, data: CreateActionItemInput!): ActionItem!
createAdmin(data: UserAndOrganizationInput!): User!
createAdvertisement(endDate: Date!, link: String!, name: String!, orgId: ID!, startDate: Date!, type: String!): Advertisement!
createCategory(category: String!, orgId: ID!): Category!
createComment(data: CommentInput!, postId: ID!): Comment
createDirectChat(data: createChatInput!): DirectChat!
createDonation(amount: Float!, nameOfOrg: String!, nameOfUser: String!, orgId: ID!, payPalId: ID!, userId: ID!): Donation!
Expand Down Expand Up @@ -536,7 +495,6 @@ type Mutation {
registerForEvent(id: ID!): Event!
rejectAdmin(id: ID!): Boolean!
rejectMembershipRequest(membershipRequestId: ID!): MembershipRequest!
removeActionItem(id: ID!): ActionItem!
removeAdmin(data: UserAndOrganizationInput!): User!
removeAdvertisement(id: ID!): Advertisement
removeComment(id: ID!): Comment
Expand Down Expand Up @@ -566,8 +524,6 @@ type Mutation {
unlikeComment(id: ID!): Comment
unlikePost(id: ID!): Post
unregisterForEventByUser(id: ID!): Event!
updateActionItem(data: UpdateActionItemInput!, id: ID!): ActionItem
updateCategory(data: UpdateCategoryInput!, id: ID!): Category
updateEvent(data: UpdateEventInput, id: ID!): Event!
updateLanguage(languageCode: String!): User!
updateOrganization(data: UpdateOrganizationInput, file: String, id: ID!): Organization!
Expand All @@ -586,7 +542,6 @@ input OTPInput {

type Organization {
_id: ID!
actionCategories: [Category]
admins(adminId: ID): [User]
apiUrl: URL!
blockedUsers: [User]
Expand Down Expand Up @@ -816,11 +771,7 @@ input PostWhereInput {
}

type Query {
actionItem(id: ID!): ActionItem
actionItemsByEvent(eventId: ID!): [ActionItem]
adminPlugin(orgId: ID!): [Plugin]
categoriesByOrganization(orgId: ID!): [Category]
category(id: ID!): Category
checkAuth: User!
customDataByOrganization(organizationId: ID!): [UserCustomData!]!
customFieldsByOrganization(id: ID!): [OrganizationCustomField]
Expand Down Expand Up @@ -909,19 +860,6 @@ type UnauthorizedError implements Error {
message: String!
}

input UpdateActionItemInput {
assignedTo: ID
completed: Boolean
dueDate: Date
postCompletionNotes: String
preCompletionNotes: String
}

input UpdateCategoryInput {
category: String
disabled: Boolean
}

input UpdateEventInput {
allDay: Boolean
description: String
Expand Down
6 changes: 3 additions & 3 deletions src/models/ActionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface InterfaceActionItem {
dueDate: Date;
completionDate: Date;
completed: boolean;
event: PopulatedDoc<InterfaceEvent & Document>;
eventId: PopulatedDoc<InterfaceEvent & Document>;
createdBy: PopulatedDoc<InterfaceUser & Document>;
createdAt: Date;
updatedAt: Date;
Expand All @@ -36,7 +36,7 @@ export interface InterfaceActionItem {
* @param dueDate - Due date.
* @param completionDate - Completion date.
* @param completed - Whether the ActionItem has been completed.
* @param event - Event to which the ActionItem is related, refer to the `Event` model.
* @param eventId - Event to which the ActionItem is related, refer to the `Event` model.
* @param createdBy - User who created the ActionItem, refer to the `User` model.
* @param createdAt - Timestamp when the ActionItem was created.
* @param updatedAt - Timestamp when the ActionItem was last updated.
Expand Down Expand Up @@ -81,7 +81,7 @@ const actionItemSchema = new Schema(
type: Boolean,
default: false,
},
event: {
eventId: {
type: Schema.Types.ObjectId,
ref: "Event",
},
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/ActionItem/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { Event } from "../../models";

export const event: ActionItemResolvers["event"] = async (parent) => {
return Event.findOne({
_id: parent.event,
_id: parent.eventId,
}).lean();
};
12 changes: 6 additions & 6 deletions src/resolvers/Mutation/createActionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ export const createActionItem: MutationResolvers["createActionItem"] = async (

let currentUserIsEventAdmin = false;

if (args.data.event) {
if (args.data.eventId) {
let currEvent: InterfaceEvent | null;

const eventFoundInCache = await findEventsInCache([args.data.event]);
const eventFoundInCache = await findEventsInCache([args.data.eventId]);

currEvent = eventFoundInCache[0];

if (eventFoundInCache[0] === null) {
currEvent = await Event.findOne({
_id: args.data.event,
_id: args.data.eventId,
}).lean();

if (currEvent !== null) {
Expand Down Expand Up @@ -153,14 +153,14 @@ export const createActionItem: MutationResolvers["createActionItem"] = async (
postCompletionNotes: args.data.postCompletionNotes,
dueDate: args.data.dueDate,
completionDate: args.data.completionDate,
event: args.data.event,
eventId: args.data.eventId,
createdBy: context.userId,
});

if (args.data.event) {
if (args.data.eventId) {
await Event.findOneAndUpdate(
{
_id: args.data.event,
_id: args.data.eventId,
},
{
$push: { actionItems: createActionItem._id },
Expand Down
10 changes: 5 additions & 5 deletions src/resolvers/Mutation/removeActionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async (

let currentUserIsEventAdmin = false;

if (actionItem.event) {
if (actionItem.eventId) {
let currEvent: InterfaceEvent | null;

const eventFoundInCache = await findEventsInCache([actionItem.event]);
const eventFoundInCache = await findEventsInCache([actionItem.eventId]);

currEvent = eventFoundInCache[0];

if (eventFoundInCache[0] === null) {
currEvent = await Event.findOne({
_id: actionItem.event,
_id: actionItem.eventId,
}).lean();

if (currEvent !== null) {
Expand Down Expand Up @@ -110,10 +110,10 @@ export const removeActionItem: MutationResolvers["removeActionItem"] = async (
);
}

if (actionItem.event) {
if (actionItem.eventId) {
await Event.updateOne(
{
_id: actionItem.event,
_id: actionItem.eventId,
},
{
$pull: { actionItems: actionItem._id },
Expand Down
6 changes: 3 additions & 3 deletions src/resolvers/Mutation/updateActionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ export const updateActionItem: MutationResolvers["updateActionItem"] = async (

let currentUserIsEventAdmin = false;

if (actionItem.event) {
if (actionItem.eventId) {
let currEvent: InterfaceEvent | null;

const eventFoundInCache = await findEventsInCache([actionItem.event]);
const eventFoundInCache = await findEventsInCache([actionItem.eventId]);

currEvent = eventFoundInCache[0];

if (eventFoundInCache[0] === null) {
currEvent = await Event.findOne({
_id: actionItem.event,
_id: actionItem.eventId,
}).lean();

if (currEvent !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/Query/actionItemsByEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const actionItemsByEvent: QueryResolvers["actionItemsByEvent"] = async (
args
) => {
const actionItems = await ActionItem.find({
event: args.eventId,
eventId: args.eventId,
}).lean();

return actionItems;
Expand Down
2 changes: 1 addition & 1 deletion src/typeDefs/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const inputs = gql`
dueDate: Date
completionDate: Date
completed: Boolean
event: ID
eventId: ID
}
input CursorPaginationInput {
Expand Down
26 changes: 13 additions & 13 deletions src/typeDefs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ export const types = gql`
# Action Item for a Category
type ActionItem {
_id: ID!
assignedTo: User!
assignedBy: User!
category: Category!
assignedTo: User
assignedBy: User
category: Category
preCompletionNotes: String
postCompletionNotes: String
assignmentDate: Date
dueDate: Date
completionDate: Date
completed: Boolean
event: Event
createdBy: User!
createdBy: User
createdAt: Date!
updatedAt: Date!
}
Expand Down Expand Up @@ -132,14 +132,14 @@ export const types = gql`
latitude: Latitude
longitude: Longitude
organization: Organization
creator: User!
attendees: [User!]!
creator: User
attendees: [User!]
# For each attendee, gives information about whether he/she has checked in yet or not
attendeesCheckInStatus: [CheckInStatus!]!
attendeesCheckInStatus: [CheckInStatus!]
admins(adminId: ID): [User]
actionItems: [ActionItem]
status: Status!
feedback: [Feedback!]!
feedback: [Feedback!]
averageFeedbackScore: Float
}
Expand Down Expand Up @@ -221,23 +221,23 @@ export const types = gql`
description: String!
location: String
isPublic: Boolean!
creator: User!
creator: User
members: [User]
admins(adminId: ID): [User]
actionCategories: [Category]
membershipRequests: [MembershipRequest]
blockedUsers: [User]
visibleInSearch: Boolean!
apiUrl: URL!
createdAt: DateTime
createdAt: DateTime!
pinnedPosts: [Post]
userTags(
after: String
before: String
first: PositiveInt
last: PositiveInt
): UserTagsConnection
customFields: [OrganizationCustomField!]!
customFields: [OrganizationCustomField!]
}
type OrganizationCustomField {
Expand Down Expand Up @@ -334,9 +334,9 @@ export const types = gql`
type Category {
_id: ID!
category: String!
org: Organization!
org: Organization
disabled: Boolean!
createdBy: User!
createdBy: User
createdAt: Date!
updatedAt: Date!
}
Expand Down
Loading

0 comments on commit dc7180e

Please sign in to comment.