1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { fetch } from "https://esm.town/v/std/fetch";
export async function ShopifyProductSearch(brokerId, first = 20) {
// The GraphQL endpoint you're going to query
const url = "https://shop.app/web/api/graphql";
// The GraphQL query
const query = `
query ShopProductSearch($brokerId: ID!, $first: Int!, $after: String, $filter: [SearchFilterV2!], $sortBy: ShopProductSearchSortByV2, $query: String) {
shopProductSearch(
brokerId: $brokerId
first: $first
after: $after
filter: $filter
sortBy: $sortBy
query: $query
) {
...ProductSearch
__typename
}
}
fragment ProductSearch on ProductSearchConnection {
nodes {
__typename
id
... on DiscoveryProduct {
id
...ShopWebRelatedProductFragment
__typename
}
}
productFilters {
...ProductFilter
__typename
}
pageInfo {
hasNextPage
endCursor
__typename
}
filter {
network
__typename
}
inferredCategoryFilters
totalCount
totalCountCapped
inferredQueryType
__typename
}
fragment ShopWebRelatedProductFragment on DiscoveryProduct {
id
price {
...MoneyV2Fragment
__typename
}
originalPrice {
...MoneyV2Fragment
__typename
}
title
url
images {
url
altText
sensitive
width
height
__typename
}
offers {
id
... on DiscountOffer {
...DiscountOffer
__typename
}
__typename
}
shopCashOffer {
id
offerHandle
boostMultiplier
totalCashDestinationAmount {
amount
currencyCode
__typename
}
__typename
}
defaultVariantId
inDefaultProductList
shop {
id
websiteUrl
name
defaultHandle
inAppVisibilityStatus
visualTheme {