Skip to content

Commit

Permalink
Fixed mutiations to match Postman E2E contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
trpubz committed Feb 10, 2024
1 parent ed23565 commit 2d6fb55
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/components/AddExpense/AddExpense.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const AddExpense = ({ totalExpenses, setTotalExpenses, setTransactions }) => {
variables: {
userId,
vendor,
category,
cat: category,
amount: amountCents,
date,
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddIncome/AddIncome.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const AddIncome = ({ totalIncome, setTotalIncome, setTransactions }) => {
try {
const { data } = await createIncome({
variables: {
userId,
userId,
source,
amount: amountCents,
date,
Expand Down
1 change: 1 addition & 0 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const App = () => {
// Hardcoded user, will pull from getUser endpoint soon
const userName = "Powdered Toast Man";
const email = "[email protected]"
localStorage.setItem('email', '[email protected]');

const { totalIncomeData } = useGetIncomes(email);
const { totalExpensesData } = useGetExpenses(email);
Expand Down
3 changes: 2 additions & 1 deletion src/components/apollo-client/apollo-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { ApolloClient, InMemoryCache, createHttpLink } from "@apollo/client";
import { setContext } from "@apollo/client/link/context";

const httpLink = createHttpLink({
uri: "https://doughfin-be.onrender.com/graphql",
// uri: "https://doughfin-be.onrender.com/graphql",
uri: "http://localhost:3000/graphql"
});

const customHeaders = setContext((_, { headers }) => {
Expand Down
31 changes: 17 additions & 14 deletions src/components/apollo-client/mutations/createExpense.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { gql, useMutation } from "@apollo/client";

export const CREATE_EXPENSE = gql`
mutation CreateExpense($userId: ID!, $vendor: String!, $category: String!, $amount: Float!, $date: String!) {
createExpense(input: {
userId: $userId,
vendor: $vendor,
category: $category,
amount: $amount,
date: $date
}) {
userId
vendor
category
amount
date
}
mutation CreateExpense($userId: ID!, $vendor: String!, $cat: String!, $amount: Float!, $date: String!) {
createExpense(input: {
userId: $userId,
vendor: $vendor,
category: $cat,
amount: $amount,
date: $date
}) {
userId
expense {
id
vendor
category
amount
date
}
}
}`

export const useCreateExpense = () => {
Expand Down
24 changes: 13 additions & 11 deletions src/components/apollo-client/mutations/createIncome.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import { gql, useMutation } from "@apollo/client";

export const CREATE_INCOME = gql`
mutation CreateIncome($userId: ID!, $source: String!, $amount: Float!, $date: String!) {
createIncome(input: {
userId: $userId,
source: $source,
amount: $amount,
date: $date
}) {
userId
source
amount
date
}
createIncome(input: {
userId: $userId,
source: $source,
amount: $amount,
date: $date
}) {
userId
income {
source
amount
date
}
}
}`;

export const useCreateIncome = () => {
Expand Down

0 comments on commit 2d6fb55

Please sign in to comment.