Skip to content

Commit

Permalink
chore: debug playright weird exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Plopix committed Jul 24, 2024
1 parent a218246 commit 06c7bb9
Showing 1 changed file with 40 additions and 37 deletions.
77 changes: 40 additions & 37 deletions shared/application/use-cases/crystallize/read/fetchCart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,67 @@ type Deps = {
};

export const fetchCart = async (cartId: string, { apiClient }: Deps): Promise<Cart | undefined> => {
try {
const query = {
cart: {
__args: {
id: cartId,
},
id: true,
state: true,
orderId: true,
customer: {
isGuest: true,
},
items: {
quantity: true,
variant: {
name: true,
sku: true,
price: {
net: true,
gross: true,
taxAmount: true,
discounts: {
amount: true,
},
},
},
const query = {
cart: {
__args: {
id: cartId,
},
id: true,
state: true,
orderId: true,
customer: {
isGuest: true,
},
items: {
quantity: true,
variant: {
name: true,
sku: true,
price: {
net: true,
gross: true,
taxAmount: true,
discounts: {
amount: true,
percent: true,
},
},
images: {
url: true,
width: true,
height: true,
altText: true,
},
},
total: {
price: {
net: true,
gross: true,
taxAmount: true,
discounts: {
amount: true,
percent: true,
},
currency: true,
},
images: {
url: true,
width: true,
height: true,
altText: true,
},
},
};
const cart = await apiClient.shopCartApi(jsonToGraphQLQuery({ query }));
total: {
net: true,
gross: true,
taxAmount: true,
discounts: {
amount: true,
percent: true,
},
currency: true,
},
},
};
const rawQuery = jsonToGraphQLQuery({ query });
try {
const cart = await apiClient.shopCartApi(rawQuery);
return cart.cart;
} catch (exception: any) {
console.error('Failed to fetch cart', exception.message);
console.error(exception);
console.error({ query: rawQuery });
return undefined;
}
};

0 comments on commit 06c7bb9

Please sign in to comment.