Initial commit

This commit is contained in:
Rami Bitar
2026-05-03 20:12:12 -04:00
commit 3a3ca1c72a
169 changed files with 22320 additions and 0 deletions

137
editor/graphql/cart.js Normal file
View File

@@ -0,0 +1,137 @@
// Cart Fragment for consistent cart data
const CartFragment = `
fragment CartFragment on Cart {
id
checkoutUrl
totalQuantity
cost {
subtotalAmount {
amount
currencyCode
}
totalAmount {
amount
currencyCode
}
totalTaxAmount {
amount
currencyCode
}
}
lines(first: 100) {
edges {
node {
id
quantity
cost {
totalAmount {
amount
currencyCode
}
}
merchandise {
... on ProductVariant {
id
title
selectedOptions {
name
value
}
price {
amount
currencyCode
}
image {
id
url
altText
width
height
}
product {
id
title
handle
vendor
}
}
}
}
}
}
}
`;
// Create a new cart
export const CREATE_CART_MUTATION = `
${CartFragment}
mutation CreateCart($lines: [CartLineInput!]) {
cartCreate(input: { lines: $lines }) {
cart {
...CartFragment
}
userErrors {
field
message
}
}
}
`;
// Add lines to cart
export const ADD_CART_LINES_MUTATION = `
${CartFragment}
mutation AddCartLines($cartId: ID!, $lines: [CartLineInput!]!) {
cartLinesAdd(cartId: $cartId, lines: $lines) {
cart {
...CartFragment
}
userErrors {
field
message
}
}
}
`;
// Update cart lines
export const UPDATE_CART_LINES_MUTATION = `
${CartFragment}
mutation UpdateCartLines($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
cartLinesUpdate(cartId: $cartId, lines: $lines) {
cart {
...CartFragment
}
userErrors {
field
message
}
}
}
`;
// Remove lines from cart
export const REMOVE_CART_LINES_MUTATION = `
${CartFragment}
mutation RemoveCartLines($cartId: ID!, $lineIds: [ID!]!) {
cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
cart {
...CartFragment
}
userErrors {
field
message
}
}
}
`;
// Get cart by ID
export const GET_CART_QUERY = `
${CartFragment}
query GetCart($cartId: ID!) {
cart(id: $cartId) {
...CartFragment
}
}
`;

View File

@@ -0,0 +1,61 @@
import { ProductFragment } from './products.js';
// Get all collections
export const GET_COLLECTIONS_QUERY = `
query GetCollections($first: Int!) {
collections(first: $first) {
edges {
node {
id
title
handle
description
descriptionHtml
image {
id
url
altText
width
height
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
`;
// Get products in a collection
export const GET_COLLECTION_PRODUCTS_QUERY = `
${ProductFragment}
query GetCollectionProducts($handle: String!, $first: Int!, $sortKey: ProductCollectionSortKeys, $reverse: Boolean) {
collection(handle: $handle) {
id
title
handle
description
descriptionHtml
image {
id
url
altText
width
height
}
products(first: $first, sortKey: $sortKey, reverse: $reverse) {
edges {
node {
...ProductFragment
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
`;

116
editor/graphql/products.js Normal file
View File

@@ -0,0 +1,116 @@
// Product Fragment for consistent product data
export const ProductFragment = `
fragment ProductFragment on Product {
id
title
handle
description
descriptionHtml
vendor
productType
tags
availableForSale
priceRange {
minVariantPrice {
amount
currencyCode
}
maxVariantPrice {
amount
currencyCode
}
}
compareAtPriceRange {
minVariantPrice {
amount
currencyCode
}
maxVariantPrice {
amount
currencyCode
}
}
images(first: 10) {
edges {
node {
id
url
altText
width
height
}
}
}
variants(first: 100) {
edges {
node {
id
title
availableForSale
selectedOptions {
name
value
}
price {
amount
currencyCode
}
compareAtPrice {
amount
currencyCode
}
image {
id
url
altText
width
height
}
}
}
}
options {
id
name
values
}
}
`;
// Get multiple products
export const GET_PRODUCTS_QUERY = `
${ProductFragment}
query GetProducts($first: Int!, $query: String, $sortKey: ProductSortKeys, $reverse: Boolean) {
products(first: $first, query: $query, sortKey: $sortKey, reverse: $reverse) {
edges {
node {
...ProductFragment
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
`;
// Get a single product by handle
export const GET_PRODUCT_QUERY = `
${ProductFragment}
query GetProduct($handle: String!) {
product(handle: $handle) {
...ProductFragment
}
}
`;
// Get product recommendations
export const QUERY_PRODUCT_RECOMMENDATIONS = `
${ProductFragment}
query GetProductRecommendations($productId: ID!) {
productRecommendations(productId: $productId) {
...ProductFragment
}
}
`;