I can update a row!

This commit is contained in:
Ben Miller
2024-11-16 04:51:23 -07:00
parent ca48bb6572
commit 6dd205dcbb
4 changed files with 73 additions and 7 deletions

46
package-lock.json generated
View File

@ -10,6 +10,8 @@
"devDependencies": {
"@types/google-apps-script": "^1.0.85",
"gas-webpack-plugin": "^2.6.0",
"graphql-tag": "^2.12.6",
"shopify-admin-api-typings": "^1.2.2",
"ts-loader": "^9.5.1",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
@ -911,6 +913,33 @@
"dev": true,
"license": "ISC"
},
"node_modules/graphql": {
"version": "16.9.0",
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz",
"integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
}
},
"node_modules/graphql-tag": {
"version": "2.12.6",
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz",
"integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==",
"dev": true,
"license": "MIT",
"dependencies": {
"tslib": "^2.1.0"
},
"engines": {
"node": ">=10"
},
"peerDependencies": {
"graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@ -1444,6 +1473,16 @@
"node": ">=8"
}
},
"node_modules/shopify-admin-api-typings": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/shopify-admin-api-typings/-/shopify-admin-api-typings-1.2.2.tgz",
"integrity": "sha512-n9NSBPBKX+TSfAr8ibpXKoGdHCUCY6WBKV2FhD9xvjGG3DIqqUylqhC3OXKiWcrTQuyb3WnaRCvl16i3uhJMiQ==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"graphql": ">=14"
}
},
"node_modules/slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
@ -1609,6 +1648,13 @@
"webpack": "^5.0.0"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"dev": true,
"license": "0BSD"
},
"node_modules/typescript": {
"version": "5.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",

View File

@ -12,8 +12,14 @@
"devDependencies": {
"@types/google-apps-script": "^1.0.85",
"gas-webpack-plugin": "^2.6.0",
"graphql-tag": "^2.12.6",
"shopify-admin-api-typings": "^1.2.2",
"ts-loader": "^9.5.1",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
},
"graphql": {
"schema": "https://localhost:3001/graphql",
"documents": "**/*.{graphql,js,ts,jsx,tsx}"
}
}

View File

@ -138,9 +138,7 @@ export class Product {
variant.sku = this.sku
variant.price = this.price
sps.variants.push(variant)
let opt = new ShopifyVa
let options = new VariantOptionValueInput()
options.id = this.shopify_default_option_value_id
console.log("ToShopifyProductSet:\n" + JSON.stringify(sps, null, 2))
return sps
}

View File

@ -16,6 +16,8 @@
/// <reference types="@types/google-apps-script" />
import { Config } from "./config"
import * as shopify from "shopify-admin-api-typings"
import gql from 'graphql-tag'
const ss = SpreadsheetApp.getActive()
@ -731,7 +733,13 @@ export class ShopifyVariant {
barcode?: string
position?: number
nodes?: ShopifyProductVariant[]
optionValues?: VariantOptionValueInput[]
//TODO: support multiple options
optionValues: [{}] = [
{
optionName: "Title",
name: "Default Title"
}
]
}
class PageInfo {
@ -802,7 +810,7 @@ export class ShopifyProductsResponse {
}
export class ShopifyProductSetQuery {
GQL: string = `mutation setProduct($productSet: ProductSetInput!) {
GQL = `mutation setProduct($productSet: ProductSetInput!) {
productSet(input: $productSet) {
product {
id
@ -826,7 +834,7 @@ export class ShopifyProductSetQuery {
JSON: JSON
constructor(product: ShopifyProductSetInput, synchronous: boolean = true) {
let j = `{
"query": ${formatGqlForJSON(this.GQL)},
"query": ${formatGqlForJSON(String(this.GQL))},
"variables": {
"productSet": ${JSON.stringify(product)}
}
@ -847,7 +855,15 @@ export class ShopifyProductSetInput {
title: string
vendor: string
variants: ShopifyVariant[]
productOptions: ShopifyProductOption[]
//TODO: Support multiple product options
productOptions: [{}] = [
{
name: "Title",
values: {
name: "Default Title"
}
}
]
}
export class ProductVariantSetInput {