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

graphql nutrition tracker #166

Merged
merged 1 commit into from
Aug 5, 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
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)
}
`
Loading