Skip to content

Instantly share code, notes, and snippets.

@mshick
Last active March 29, 2023 22:49
Show Gist options
  • Save mshick/037e22ef993a1e8496919c38fcf32ed2 to your computer and use it in GitHub Desktop.
Save mshick/037e22ef993a1e8496919c38fcf32ed2 to your computer and use it in GitHub Desktop.
pr3921
{
  "defaultLocale": "en-us",
  "locales": ["en-us"],
  "queries": {
    "getCharacter": {
      "resolver": {
        "compose": [
          {
            "id": "foobar",
            "name": "rest:get",
            "service": "rick",
            "path": "/character/700"
          },
          {
            "if": "$resolvers.foobar === 500",
            "name": "rest:get",
            "service": "rick",
            "path": "/character/500"
          },
          {
            "if": "$resolvers.foobar === 500",
            "id": "another",
            "name": "rest:get",
            "service": "rick",
            "path": "/character/500"
          },
          {
            "id": "RICK",
            "name": "rest:get",
            "service": "rick",
            "path": "/character/800"
          }
        ],
        "results": {
          "ops": [
            {"path": "first", "mapping": "$resolvers.foobar"},
            {"path": "secibd", "mapping": "$resolvers.RICK"}
          ]
        }
      },
      "shape": "CharacterResponse"
    },
    "getCharacterSingle": {
      "resolver": {
        "compose": [
          {
            "id": "foobar",
            "name": "rest:get",
            "service": "rick",
            "path": "/character/700"
          }
        ]
      },
      "shape": "Character"
    },
    "Shopify_products": {
      "resolver": {
        "name": "graphql:query",
        "service": "shopify",
        "fieldName": "products"
      },
      "args": {
        "type": "object",
        "properties": {
          "first": {
            "type": "integer",
            "description": "Returns up to the first `n` elements from the list."
          },
          "after": {
            "type": "string",
            "description": "Returns the elements that come after the specified cursor."
          },
          "last": {
            "type": "integer",
            "description": "Returns up to the last `n` elements from the list."
          },
          "before": {
            "type": "string",
            "description": "Returns the elements that come before the specified cursor."
          },
          "reverse": {
            "type": "boolean",
            "description": "Reverse the order of the underlying list.",
            "default": false
          },
          "sortKey": {
            "@ref": "shopify:ProductSortKeys",
            "description": "Sort the underlying list by the given key.",
            "default": "ID"
          },
          "query": {
            "type": "string",
            "description": "Supported filter parameters:\n - `barcode`\n - `bundles`\n - `created_at`\n - `delivery_profile_id`\n - `error_feedback`\n - `gift_card`\n - `has_only_composites`\n - `has_only_default_variant`\n - `has_variant_with_components`\n - `id`\n - `inventory_total`\n - `is_price_reduced`\n - `out_of_stock_somewhere`\n - `price`\n - `product_type`\n - `publishable_status`\n - `published_status`\n - `sku`\n - `status`\n - `tag`\n - `tag_not`\n - `title`\n - `updated_at`\n - `vendor`\n\nSee the detailed [search syntax](https://shopify.dev/api/usage/search-syntax)\nfor more information about using filters."
          },
          "savedSearchId": {
            "type": "string",
            "@tag": "id",
            "description": "The ID of an existing saved search.\nThe search’s query string is used as the query argument.\nRefer to [SavedSearch](https://shopify.dev/api/admin-graphql/latest/objects/savedsearch)."
          }
        }
      },
      "shape": "Shopify_ProductConnection"
    },
    "getIndexedShopifyProductList": {
      "shape": "PaginatedList<Shopify_Product>",
      "resolver": {
        "shapeName": "Shopify_Product",
        "name": "takeshape:queryApiIndex",
        "service": "takeshape:local",
        "options": {"indexedShape": "Shopify_Product"}
      },
      "description": "Fetch Shopify_Product data from the API Index.11111",
      "args": "TSListArgs<Shopify_Product>"
    },
    "Shopify_product": {
      "resolver": {
        "name": "graphql:query",
        "service": "shopify",
        "fieldName": "product"
      },
      "args": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "@tag": "id",
            "description": "The ID of the Product to return."
          }
        },
        "required": ["id"]
      },
      "shape": "Shopify_Product"
    },
    "RickG_character": {
      "resolver": {
        "name": "graphql:query",
        "service": "rick-g",
        "fieldName": "character"
      },
      "args": {
        "type": "object",
        "properties": {"id": {"type": "string", "@tag": "id"}},
        "required": ["id"]
      },
      "shape": "RickG_Character"
    },
    "getProduct": {
      "shape": "Product",
      "resolver": {
        "name": "takeshape:get",
        "service": "takeshape:local",
        "shapeName": "Product"
      },
      "description": "Get a Product by ID",
      "args": "TSGetArgs<Product>"
    },
    "getProductList": {
      "shape": "PaginatedList<Product>",
      "resolver": {
        "name": "takeshape:list",
        "service": "takeshape:local",
        "shapeName": "Product"
      },
      "description": "Returns a list Product in natural order.",
      "args": "TSListArgs<Product>"
    }
  },
  "mutations": {
    "Shopify_customerCreate": {
      "resolver": {
        "name": "graphql:mutation",
        "service": "shopify",
        "fieldName": "customerCreate"
      },
      "args": {
        "type": "object",
        "properties": {
          "input": {
            "@ref": "shopify:CustomerInput",
            "description": "The input fields to create a customer."
          }
        },
        "required": ["input"]
      },
      "shape": "Shopify_CustomerCreatePayload"
    },
    "Shopify_customerPaymentMethodCreditCardUpdate": {
      "resolver": {
        "name": "graphql:mutation",
        "service": "shopify",
        "fieldName": "customerPaymentMethodCreditCardUpdate"
      },
      "args": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "@tag": "id",
            "description": "The ID of the customer payment method."
          },
          "billingAddress": {
            "@ref": "shopify:MailingAddressInput",
            "description": "The billing address."
          },
          "sessionId": {
            "type": "string",
            "description": "The Cardserver session ID."
          }
        },
        "required": ["id", "billingAddress", "sessionId"]
      },
      "shape": "Shopify_CustomerPaymentMethodCreditCardUpdatePayload"
    },
    "Shopify_productUpdate": {
      "resolver": {
        "name": "graphql:mutation",
        "service": "shopify",
        "fieldName": "productUpdate"
      },
      "args": {
        "type": "object",
        "properties": {
          "input": {
            "@ref": "shopify:ProductInput",
            "description": "The updated properties for a product."
          }
        },
        "required": ["input"]
      },
      "shape": "Shopify_ProductUpdatePayload"
    },
    "updateProduct": {
      "shape": "UpdateResult<Product>",
      "resolver": {
        "compose": [
          {
            "id": "createNewShopifyObject",
            "if": "isEmpty(args.input.shopifyProductId) && !isEmpty(args.input.shopifyProduct)",
            "name": "graphql:mutation",
            "service": "shopify",
            "fieldName": "productCreate",
            "options": {"selectionSet": "{ product { id } }"},
            "args": {
              "ops": [
                {
                  "path": "input.descriptionHtml",
                  "mapping": "$args.input.shopifyProduct.descriptionHtml"
                },
                {
                  "path": "input.handle",
                  "mapping": "$args.input.shopifyProduct.handle"
                },
                {
                  "path": "input.redirectNewHandle",
                  "mapping": "$args.input.shopifyProduct.redirectNewHandle"
                },
                {
                  "path": "input.productType",
                  "mapping": "$args.input.shopifyProduct.productType"
                },
                {
                  "path": "input.tags",
                  "mapping": "$args.input.shopifyProduct.tags"
                },
                {
                  "path": "input.templateSuffix",
                  "mapping": "$args.input.shopifyProduct.templateSuffix"
                },
                {
                  "path": "input.giftCard",
                  "mapping": "$args.input.shopifyProduct.giftCard"
                },
                {
                  "path": "input.giftCardTemplateSuffix",
                  "mapping": "$args.input.shopifyProduct.giftCardTemplateSuffix"
                },
                {
                  "path": "input.title",
                  "mapping": "$args.input.shopifyProduct.title"
                },
                {
                  "path": "input.vendor",
                  "mapping": "$args.input.shopifyProduct.vendor"
                },
                {
                  "path": "input.bodyHtml",
                  "mapping": "$args.input.shopifyProduct.bodyHtml"
                }
              ]
            }
          },
          {
            "id": "editTakeshape",
            "name": "takeshape:update",
            "service": "takeshape:local",
            "shapeName": "Product",
            "args": {
              "ops": [
                {"path": "input", "mapping": "$args.input"},
                {
                  "path": "input.shopifyProductId",
                  "mapping": [
                    [
                      "get",
                      {"path": "$resolvers.createNewShopifyObject.product.id"}
                    ],
                    ["get", {"path": "$args.input.shopifyProductId"}]
                  ]
                }
              ]
            }
          },
          {
            "id": "updateExistingShopifyObject",
            "if": "!isEmpty(args.input.shopifyProductId) && !isEmpty(args.input.shopifyProduct)",
            "name": "graphql:mutation",
            "service": "shopify",
            "fieldName": "productUpdate",
            "options": {"selectionSet": "{ product { id } }"},
            "args": {
              "ops": [
                {
                  "path": "input.descriptionHtml",
                  "mapping": "$args.input.shopifyProduct.descriptionHtml"
                },
                {
                  "path": "input.handle",
                  "mapping": "$args.input.shopifyProduct.handle"
                },
                {
                  "path": "input.redirectNewHandle",
                  "mapping": "$args.input.shopifyProduct.redirectNewHandle"
                },
                {
                  "path": "input.productType",
                  "mapping": "$args.input.shopifyProduct.productType"
                },
                {
                  "path": "input.tags",
                  "mapping": "$args.input.shopifyProduct.tags"
                },
                {
                  "path": "input.templateSuffix",
                  "mapping": "$args.input.shopifyProduct.templateSuffix"
                },
                {
                  "path": "input.giftCard",
                  "mapping": "$args.input.shopifyProduct.giftCard"
                },
                {
                  "path": "input.giftCardTemplateSuffix",
                  "mapping": "$args.input.shopifyProduct.giftCardTemplateSuffix"
                },
                {
                  "path": "input.title",
                  "mapping": "$args.input.shopifyProduct.title"
                },
                {
                  "path": "input.vendor",
                  "mapping": "$args.input.shopifyProduct.vendor"
                },
                {
                  "path": "input.bodyHtml",
                  "mapping": "$args.input.shopifyProduct.bodyHtml"
                },
                {"path": "input.id", "mapping": "$args.input.shopifyProductId"}
              ]
            }
          }
        ],
        "results": {
          "ops": [
            {"path": "result", "mapping": "$resolvers.editTakeshape.result"}
          ]
        }
      },
      "description": "Update Product. If the input has Shopify values and a Shopify ID, the Shopify product with that ID is updated.\nIf the input has Shopify values and no Shopify ID, a Shopify product is created.",
      "args": "UpdateArgs<Product>"
    },
    "createProduct": {
      "shape": "CreateResult<Product>",
      "resolver": {
        "compose": [
          {
            "id": "shopifyCreate",
            "if": "!isEmpty(args.input.shopifyProduct)",
            "name": "graphql:mutation",
            "service": "shopify",
            "fieldName": "productCreate",
            "options": {"selectionSet": "{ product { id } }"},
            "args": {
              "ops": [
                {
                  "path": "input.descriptionHtml",
                  "mapping": "$args.input.shopifyProduct.descriptionHtml"
                },
                {
                  "path": "input.handle",
                  "mapping": "$args.input.shopifyProduct.handle"
                },
                {
                  "path": "input.redirectNewHandle",
                  "mapping": "$args.input.shopifyProduct.redirectNewHandle"
                },
                {
                  "path": "input.productType",
                  "mapping": "$args.input.shopifyProduct.productType"
                },
                {
                  "path": "input.tags",
                  "mapping": "$args.input.shopifyProduct.tags"
                },
                {
                  "path": "input.templateSuffix",
                  "mapping": "$args.input.shopifyProduct.templateSuffix"
                },
                {
                  "path": "input.giftCard",
                  "mapping": "$args.input.shopifyProduct.giftCard"
                },
                {
                  "path": "input.giftCardTemplateSuffix",
                  "mapping": "$args.input.shopifyProduct.giftCardTemplateSuffix"
                },
                {
                  "path": "input.title",
                  "mapping": "$args.input.shopifyProduct.title"
                },
                {
                  "path": "input.vendor",
                  "mapping": "$args.input.shopifyProduct.vendor"
                },
                {
                  "path": "input.bodyHtml",
                  "mapping": "$args.input.shopifyProduct.bodyHtml"
                }
              ]
            }
          },
          {
            "id": "creatingShopifyObject",
            "if": "!isEmpty(args.input.shopifyProduct)",
            "name": "takeshape:create",
            "service": "takeshape:local",
            "shapeName": "Product",
            "args": {
              "ops": [
                {"path": "input", "mapping": "$args.input"},
                {
                  "path": "input.shopifyProductId",
                  "mapping": "$resolvers.shopifyCreate.product.id"
                }
              ]
            }
          },
          {
            "id": "notCreatingShopifyObject",
            "if": "isEmpty(args.input.shopifyProduct)",
            "name": "takeshape:create",
            "service": "takeshape:local",
            "shapeName": "Product",
            "args": {"ops": [{"path": "input", "mapping": "$args.input"}]}
          }
        ],
        "results": {
          "ops": [
            {
              "path": "result",
              "mapping": [
                ["get", {"path": "$resolvers.creatingShopifyObject.result"}],
                ["get", {"path": "$resolvers.notCreatingShopifyObject.result"}]
              ]
            }
          ]
        }
      },
      "description": "Create Product. If Shopify values are provided, a Shopify product is also created and the new product ID is saved.",
      "args": "CreateArgs<Product>"
    },
    "duplicateProduct": {
      "shape": "DuplicateResult<Product>",
      "resolver": {
        "name": "takeshape:duplicate",
        "service": "takeshape:local",
        "shapeName": "Product"
      },
      "description": "Duplicate Product",
      "args": "DuplicateArgs<Product>"
    },
    "deleteProduct": {
      "shape": "DeleteResult<Product>",
      "resolver": {
        "name": "takeshape:delete",
        "service": "takeshape:local",
        "shapeName": "Product"
      },
      "description": "Delete Product",
      "args": "DeleteArgs<Product>"
    }
  },
  "shapes": {
    "Shopify_Product": {
      "id": "Shopify_Product",
      "name": "Shopify_Product",
      "title": "Shopify Product",
      "schema": {"extends": [{"@ref": "shopify:Product"}]}
    },
    "Character": {
      "id": "Character",
      "name": "Character",
      "title": "Character",
      "schema": {
        "type": "object",
        "properties": {"id": {"type": "number"}, "name": {"type": "string"}}
      }
    },
    "CharacterResponse": {
      "id": "CharacterResponse",
      "name": "CharacterResponse",
      "title": "CharacterResponse",
      "schema": {
        "type": "object",
        "properties": {
          "first": {"@ref": "takeshape:local:Character"},
          "second": {"@ref": "takeshape:local:Character"}
        }
      }
    },
    "Product": {
      "name": "Product",
      "id": "32seFQFbq",
      "title": "Product",
      "workflow": "default",
      "model": {"type": "multiple"},
      "schema": {
        "type": "object",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string",
            "description": "Initialized with title from shopify",
            "@mapping": "takeshape:local:Product.-vVg9XOY2v"
          },
          "shopifyProduct": {
            "@ref": "shopify:Product",
            "@resolver": {
              "name": "graphql:query",
              "service": "shopify",
              "fieldName": "product",
              "args": {
                "ops": [{"path": "id", "mapping": "$source.shopifyProductId"}]
              }
            },
            "@tag": "pattern:service-object:1",
            "@input": {"@ref": "shopify:ProductInput"}
          },
          "shopifyProductId": {
            "type": "string",
            "@mapping": "takeshape:local:Product.shopifyProductId",
            "title": "shopify product",
            "minLength": 1,
            "pattern": "(^gid://shopify/Product/\\d+$)"
          }
        }
      }
    }
  },
  "workflows": {},
  "forms": {
    "Product": {
      "default": {
        "properties": {
          "name": {"widget": "singleLineText"},
          "shopifyProduct": {
            "properties": {
              "descriptionHtml": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "handle": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "redirectNewHandle": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "productType": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "tags": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "templateSuffix": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "giftCard": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "giftCardTemplateSuffix": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "title": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "vendor": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "bodyHtml": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "images": {
                "widget": "shopifyProductImages",
                "provider": "shopify"
              },
              "publishedAt": {
                "widget": "serviceObjectProperty",
                "provider": "shopify"
              },
              "variants": {
                "widget": "shopifyRelationshipSummary",
                "provider": "shopify"
              }
            },
            "widget": "shopify",
            "wrapper": "shopifyServiceWrapper",
            "order": [
              "title",
              "handle",
              "descriptionHtml",
              "bodyHtml",
              "tags",
              "vendor",
              "publishedAt",
              "variants",
              "images",
              "redirectNewHandle",
              "productType",
              "templateSuffix",
              "giftCard",
              "giftCardTemplateSuffix"
            ]
          },
          "shopifyProductId": {
            "instructions": "Format: gid://shopify/Product/1111111111111",
            "label": "product ID",
            "widget": "serviceObjectId",
            "provider": "shopify",
            "serviceObjectType": "product",
            "service": "shopify"
          }
        },
        "order": ["name", "shopifyProductId", "shopifyProduct"]
      }
    }
  },
  "schemaVersion": "3.28.0",
  "apiVersion": "2",
  "services": {
    "shopify": {
      "id": "shopify",
      "provider": "shopify",
      "title": "Shopify",
      "namespace": "Shopify",
      "serviceType": "graphql",
      "authenticationType": "custom",
      "authentication": "B3Jp3+fDWnutvSWyQ46mscU67x0SoYqPFYWHCq6pgMyclP+yu17Ti67D4Cm0haktmYvZWJsorLoOg2EluBbzQF+Eyb5uuqwY6MEcme+faXLX+N3+D+Cnnqog6/N9lFH6aIXnvBXovTHIf8uEITnx8BsTflv7Y6XWo+81X9rSyLsOFmAqnYIwtZYWVCn36OTM/mY=",
      "options": {
        "shop": "deluxe-sample-project",
        "endpoint": "https://deluxe-sample-project.myshopify.com/admin/api/2022-07/graphql.json"
      }
    },
    "rick": {
      "id": "rick",
      "provider": "rest",
      "title": "Rick",
      "namespace": "Rick",
      "serviceType": "rest",
      "authenticationType": "searchParams",
      "options": {"endpoint": "https://rickandmortyapi.com/api"},
      "authentication": "bq+TXmceCZGQ2BZ77pcXDJecUWawxINyUD9KjkD29YenBrG6EjP7SJVWWYqR+5r5wh6g1oVB2i2eLWbz7I0mWNkWCXxO/Rl7YW2Vmx5CdQgRA8XX3g=="
    },
    "rick-g": {
      "id": "rick-g",
      "provider": "graphql",
      "title": "RickG",
      "namespace": "RickG",
      "serviceType": "graphql",
      "authenticationType": "none",
      "options": {"endpoint": "https://rickandmortyapi.com/graphql"}
    }
  },
  "indexedShapes": {
    "Shopify_Product": {
      "query": {"maxDepth": 2},
      "queries": {
        "list": {"name": "Shopify_products"},
        "get": {"name": "Shopify_product"}
      },
      "triggers": [
        {"type": "schedule", "query": "list", "interval": 1445},
        {
          "type": "webhook",
          "query": "get",
          "service": "shopify",
          "events": ["products/create", "products/update", "products/delete"]
        }
      ]
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment