Skip to content

Commit

Permalink
graphql nutrition tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
tahmid-saj committed Aug 5, 2024
1 parent a60ae06 commit 4aaadd3
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import { PersistGate } from "redux-persist/integration/react"

import { ApolloClient, InMemoryCache, ApolloProvider } from "@apollo/client"

const client = new ApolloClient({
uri: "http://localhost:8000/graphql",
cache: new InMemoryCache()
})
// const client = new ApolloClient({
// uri: "http://localhost:8000/graphql",
// cache: new InMemoryCache()
// })

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<ApolloProvider client={ client }>
{/* <ApolloProvider client={ client }> */}
<ResponsiveStylingProvider>
<Provider store={ store }>
{/* <PersistGate loading={ null } persistor={ persistor }> */}
Expand Down Expand Up @@ -64,7 +64,7 @@ root.render(
{/* </PersistGate> */}
</Provider>
</ResponsiveStylingProvider>
</ApolloProvider>
{/* </ApolloProvider> */}
</React.StrictMode>
);

Expand Down
62 changes: 62 additions & 0 deletions src/utils/graphql/nutrition-tracker.graphql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { gql } from "@apollo/client";

// graphql nutrition tracker queries
export const NUTRITION_TRACKED_DAYS_BY_USER = gql`
query NutritionTrackedDaysByUser($userId: String!, $email: String!) {
nutritionTrackedDaysByUser(userId: $userId, email: $email) {
dateTracked
calories
macronutrients {
carbohydrates
protein
fat
}
micronutrients {
exerciseName
amount
unit
}
}
}
`

export const NUTRITION_TRACKED_DAYS_SUMMARY_BY_USER = gql`
query NutritionTrackedDaysSummaryByUser($userId: String!, $email: String!) {
nutritionTrackedDaysSummaryByUser(userId: $userId, email: $email) {
averageDailyCaloriesConsumption
averageDailyCarbohydratesConsumption
averageDailyFatConsumption
}
}
`

// graphql nutrition tracker mutations
export const CREATE_USER_NUTRITION_TRACKED_DAY = gql`
mutation CreateUserNutritionTrackedDay($userId: String!, $email: String!, $nutritionTrackedDay: NutritionTrackedDayInfo!) {
createUserNutritionTrackedDay(userId: $userId, email: $email, nutritionTrackedDay: $nutritionTrackedDay)
}
`

export const DELETE_USER_NUTRITION_TRACKED_DAY = gql`
mutation DeleteUserNutritionTrackedDay($userId: String!, $email: String!, $nutritionTrackedDate: String!) {
deleteUserNutritionTrackedDay(userId: $userId, email: $email, nutritionTrackedDate: $nutritionTrackedDate)
}
`

export const UPDATE_USER_NUTRITION_TRACKED_DAY = gql`
mutation UpdateUserNutritionTrackedDay($userId: String!, $email: String!, $nutritionTrackedDayInfoUpdate: NutritionTrackedDayInfoUpdate!) {
updateUserNutritionTrackedDay(userId: $userId, email: $email, nutritionTrackedDayInfoUpdate: $nutritionTrackedDayInfoUpdate)
}
`

export const UPDATE_USER_NUTRITION_TRACKED_DAYS = gql`
mutation UpdateUserNutritionTrackedDays($userId: String!, $email: String!, $nutritionTrackedDays: [NutritionTrackedDayInfo]!) {
updateUserNutritionTrackedDays(userId: $userId, email: $email, nutritionTrackedDays: $nutritionTrackedDays)
}
`

export const UPDATE_USER_NUTRITION_TRACKED_DAYS_SUMMARY = gql`
mutation UpdateUserNutritionTrackedDaysSummary($userId: String!, $email: String!, $nutritionTrackedDaysSummary: NutritionTrackedDaysSummaryInfo!) {
updateUserNutritionTrackedDaysSummary(userId: $userId, email: $email, nutritionTrackedDaysSummary: $nutritionTrackedDaysSummary)
}
`

0 comments on commit 4aaadd3

Please sign in to comment.