Skip to content
Open
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"apollo-tracing": "^0.4.0",
"bcrypt-nodejs": "^0.0.3",
"body-parser": "^1.15.0",
"chai-as-promised": "^7.1.1",
"chai-datetime": "^1.5.0",
"compression": "^1.7.3",
"cors": "^2.8.1",
Expand Down
20 changes: 20 additions & 0 deletions src/apollo/resolvers/mealPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { IContext, IObjectId } from 'types/global';
import {
IMealEvent,
IMealEventAddInput,
IMealEventEditInput,
IMealMacro,
IMealPlanRangeInput,
IWorkoutEvent,
IWorkoutEventAddInput,
IWorkoutEventEditInput,
} from 'types/mealPlan';

import { IRecipe } from 'types/recipe';
Expand All @@ -16,6 +19,8 @@ import { IAccount } from 'types/account';

export default {
MealEvent: {
macros: async (mealEvent: { _id: IObjectId }): Promise<IMealMacro> =>
MealPlan.getMealMacros(mealEvent._id),
recipes: async (mealEvent: { recipes: IObjectId[] }): Promise<IRecipe[]> =>
Recipe.findByIds(mealEvent.recipes),
},
Expand Down Expand Up @@ -45,6 +50,21 @@ export default {
data: IWorkoutEventAddInput,
ctx: IContext
): Promise<IWorkoutEvent> => MealPlan.addWorkoutEvent(data, ctx),
deleteEvent: async (
_: object,
{ id }: { id: IObjectId },
ctx: IContext
): Promise<boolean> => MealPlan.deleteEvent(id, ctx),
editMealEvent: async (
_: object,
data: IMealEventEditInput,
ctx: IContext
): Promise<IMealEvent> => MealPlan.editMealEvent(data, ctx),
editWorkoutEvent: async (
_: object,
data: IWorkoutEventEditInput,
ctx: IContext
): Promise<IWorkoutEvent> => MealPlan.editWorkoutEvent(data, ctx),
},
Query: {
mealPlanEvents: async (
Expand Down
31 changes: 29 additions & 2 deletions src/apollo/types/mealPlan.gql
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ interface MealPlanEvent {
owner: Account
}

type MealMacros {
carbs: Float
protein: Float
fat: Float
calories: Float
}

type MealEvent implements MealPlanEvent {
_id: ID
startTime: Date
endTime: Date
owner: Account
mealType: String
recipes: [Recipe]
macros: MealMacros
}

type WorkoutEvent implements MealPlanEvent {
Expand All @@ -30,11 +38,25 @@ input MealEventAddInput {
mealType: String!
}

input MealEventEditInput {
_id: ID!
startTime: Date!
endTime: Date!
recipes: [ID]!
mealType: String!
}

input WorkoutEventAddInput {
startTime: Date!
endTime: Date!
}

input WorkoutEventEditInput {
_id: ID!
startTime: Date!
endTime: Date!
}

input MealPlanRangeInput {
startDay: Date!
endDay: Date!
Expand All @@ -49,5 +71,10 @@ type Mutation {
@auth(role: USER)
addWorkoutEvent(input: WorkoutEventAddInput!): WorkoutEvent
@auth(role: USER)
# deleteRecipe(id: ID!): Boolean @auth(role: USER)
}
deleteEvent(id: ID!): Boolean
@auth(role: USER)
editMealEvent(input: MealEventEditInput!): MealEvent
@auth(role: USER)
editWorkoutEvent(input: WorkoutEventEditInput!): WorkoutEvent
@auth(role: USER)
}
2 changes: 1 addition & 1 deletion src/apollo/types/recipe.gql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type RecipeRating {
}

type Recipe {
id: ID
_id: ID
slug: String
title: String
description: String
Expand Down
1 change: 0 additions & 1 deletion src/context/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default class Auth {
}

public async signup(data: ISignupInput): Promise<IAccount> {
console.log('Here', data);
const doesAccountExist = await AccountContext.emailExists(data.input.email);

if (doesAccountExist) {
Expand Down
Loading