Skip to content

Commit 420148e

Browse files
committed
Fix GQL
1 parent 1f9f00c commit 420148e

File tree

2 files changed

+59
-65
lines changed

2 files changed

+59
-65
lines changed

utils/gql/GQL_MUTATIONS.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { gql } from '@apollo/client';
22
export const ADD_TO_CART = gql`
33
mutation ($input: AddToCartInput!) {
4+
45
addToCart(input: $input) {
5-
cartItem {
6-
key
7-
product {
6+
cartItem {
7+
key
8+
product {
9+
node {
810
id
911
databaseId
1012
name
@@ -27,7 +29,9 @@ export const ADD_TO_CART = gql`
2729
}
2830
}
2931
}
30-
variation {
32+
}
33+
variation {
34+
node {
3135
id
3236
databaseId
3337
name
@@ -51,13 +55,16 @@ export const ADD_TO_CART = gql`
5155
}
5256
}
5357
}
54-
quantity
55-
total
56-
subtotal
57-
subtotalTax
5858
}
59+
quantity
60+
total
61+
subtotal
62+
subtotalTax
5963
}
6064
}
65+
66+
67+
}
6168
`;
6269
export const CHECKOUT_MUTATION = gql`
6370
mutation CHECKOUT_MUTATION($input: CheckoutInput!) {

utils/gql/GQL_QUERIES.js

Lines changed: 44 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ export const FETCH_FIRST_PRODUCTS_FROM_HOODIES_QUERY = `
108108
*/
109109
export const FETCH_ALL_PRODUCTS_QUERY = gql`
110110
query MyQuery {
111-
products(first: 200) {
111+
products(first: 50) {
112112
nodes {
113-
id
114113
databaseId
115114
name
116115
onSale
@@ -119,11 +118,13 @@ export const FETCH_ALL_PRODUCTS_QUERY = gql`
119118
sourceUrl
120119
}
121120
... on SimpleProduct {
121+
databaseId
122122
price
123123
regularPrice
124124
salePrice
125125
}
126126
... on VariableProduct {
127+
databaseId
127128
price
128129
regularPrice
129130
salePrice
@@ -219,54 +220,58 @@ export const GET_CART = gql`
219220
nodes {
220221
key
221222
product {
222-
id
223-
databaseId
224-
name
225-
description
226-
type
227-
onSale
228-
slug
229-
averageRating
230-
reviewCount
231-
image {
223+
node {
232224
id
233-
sourceUrl
234-
srcSet
235-
altText
236-
title
237-
}
238-
galleryImages {
239-
nodes {
225+
databaseId
226+
name
227+
description
228+
type
229+
onSale
230+
slug
231+
averageRating
232+
reviewCount
233+
image {
240234
id
241235
sourceUrl
242236
srcSet
243237
altText
244238
title
245239
}
240+
galleryImages {
241+
nodes {
242+
id
243+
sourceUrl
244+
srcSet
245+
altText
246+
title
247+
}
248+
}
246249
}
247250
}
248251
variation {
249-
id
250-
databaseId
251-
name
252-
description
253-
type
254-
onSale
255-
price
256-
regularPrice
257-
salePrice
258-
image {
252+
node {
259253
id
260-
sourceUrl
261-
srcSet
262-
altText
263-
title
264-
}
265-
attributes {
266-
nodes {
254+
databaseId
255+
name
256+
description
257+
type
258+
onSale
259+
price
260+
regularPrice
261+
salePrice
262+
image {
267263
id
268-
name
269-
value
264+
sourceUrl
265+
srcSet
266+
altText
267+
title
268+
}
269+
attributes {
270+
nodes {
271+
id
272+
name
273+
value
274+
}
270275
}
271276
}
272277
}
@@ -276,25 +281,7 @@ export const GET_CART = gql`
276281
subtotalTax
277282
}
278283
}
279-
appliedCoupons {
280-
nodes {
281-
id
282-
databaseId
283-
discountType
284-
amount
285-
dateExpiry
286-
products {
287-
nodes {
288-
id
289-
}
290-
}
291-
productCategories {
292-
nodes {
293-
id
294-
}
295-
}
296-
}
297-
}
284+
298285
subtotal
299286
subtotalTax
300287
shippingTax

0 commit comments

Comments
 (0)