Products API
This document defines Ucraft Next product types, specifications, and APIs (GraphQL).
GraphQL is an API specification and can be called a query language for API and a runtime for fulfilling those queries with data. GraphQL allows clients to define the data structure required from an API call. So you can know what data structure the server will return.
Requesting data in this way enables a much more efficient way for clients' side applications to interact with back-end API and services. Hence, this method of data request:
- Reduce Under-Fetching
- Prevent Over-Fetching
- Prevent Type Errors
GraphQL API consists of three main parts:
- Schema
- Resolvers
- Database
For more information, go to GraphQL's official website.
Authentication
In Ucraft Next, the Authentication is configured through SSO (Single Sign-On).
Take the following steps to get authenticated access to commerce:
- Register in the SSO server.
- Log in with your credentials to the SSO server.
- Take the bearer token and place it in the headers of each commerce call.
- Once the steps mentioned above are taken, you are logged in.
Below is the example of the bearer token:
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJhNmQ1OTc4OGVkOGI0ZGFiNmY2MjRiYjQ4MWQ2YjYx
MmM5ODliYWI0YTUyMGJlN2NjZDEyZWQ5ZmQwMzViNjNkNTc3NzgzODEwYzRkZDk5NCIsImlhdCI6MTY2MTk0NzA4NS
45MjQ1NzIsIm5iZiI6MTY2MTk0NzA4NS45MjQ1NzQsImV4cCI6MTY2MTk1NDI4NSwic3ViIjoiMSJ9.dBjtoZqdQTF
XV2V6EDTgZq99c8AT6LG2zlRAJtkPRUc8b2kRWoJ4DkqhBwf8S1ZIdgXAUY73OvH_wdM2VU5Ok07fQphVECboLKw0Z
FMsrnPMUPjjaD5qQ2ZB2KQNz-MkmXfJ7QeHB34DzIXABQVuJF5cjlv6C6yVxZsuRHRkHVg1bL1Y5j2GBAZb3BHwpk
Bf8-mUm6NM9VUB6hr9TOqb3fwDbkmqS9SpSR2yjffCrs7caWoXskflGH31p4jElOVZDc_Xeysy3BI-doqHHznuSq6
-ceR7Syuh5RCYgrbhnLVTj76LXrv0JMiWrolKT33rqecy-Ec-LE9Y2g08-KM2uQ
GraphQL Playground
The following link stands for the GraghQL SSO stage, where you can play with queries and mutations. If you receive 403 error, please contact us to gain access.
Product Types Overview
The paragraph describes general info on product types. You can attach media files for all product types. The media types can be images, videos, and so on.
The product components include Slugs and SKUs. Slugs are used to get products via URLs. For more info on slugs, refer here. SKU stands for the Stock Keeping Unit. It refers to a unique identifier. They are used to keep track of products. For more info on SKUs, refer here.
Ucraft Next supports the following product types:
Each product type in GraphQL has (or owns) a specific GraphQL type.
All product types implement a generic GraphQL ProductTypeInterface
interface. The construction includes the union of the product as well.
The following code block represents the product type interface (GraphQL).
Interface/ProductTypeInterface
interface ProductTypeInterface {
""" Unique identifier of the product. """
id: ID!
""" The type of the product. """
type: ProductType!
""" The attribute family ID of the product. """
attributeFamilyId: ID!
""" The attribute family of the product. """
attributeFamily: AttributeFamily!
""" The stock keeping unit of the product (**SKU**). """
**sku**: String!
""" The values of all filled-in attributes for the product. """
attributeValues: [ProductAttributeValue!]!
""" The options of all filled-in attributes for the product. Only for the attributes which can have options (select, multiselect, checkbox). """
attributeOptions: [ProductAttributeOption!]
""" The categories of the product. """
categories: [Category!]!
""" The media images of the product. """
mediaImages: [MediaItem!]
""" The products which are related to this product. """
relatedProducts: [Product]
""" Upgraded option of the product. """
upSells: [Product]
""" Related items to the product. """
crossSells: [Product]
""" The creation date of the product. """
createdAt: DateTime
""" The last updated date of the product. """
updatedAt: DateTime
""" The total number of reviews. """
reviewCount: Int!
""" The average rate of the product. """
avgRating: Float!
""" All the reviews of the product. """
reviews(input: PaginateCustomerReviewInput!
""" All the ratings of the product. """
rating: [Rating!]!
}
The following table describes the notion of upselling and cross-selling:
Upsells | Cross-sells |
---|---|
Upselling encourages users to buy a higher-end product compared to the one considered to be obtained. | Cross-selling encourages clients to buy related or complementary products. |
Main Components of an eCommerce Shop
The product's lifecycle includes the company (tenant), channel, locale, currency, etc. You come across those concepts while working with the product API. They are:
Each of them is described thoroughly in their separate paragraphs.
Company/Tenant
The company is the instance of the commerce store with its appropriate data. The Tenant type is the company's GraphQL type.
In general, it includes the main data about the tenant, such as store name, owner's email, username, domain, store description, active or inactive state of the store, default channel ID, details about the tenant, channel data, default attribute family data, default inventory source data and so on.
The following code block represents the Tenant/Company type.
type Tenant {
id: ID!
name: String!
email: String!
username: String!
domain: String!
cname: String
description: String
moreInfo: String!
isActive: Boolean!
channelId: Int!
details: TenantDetails!
channels: [Channel!]
defaultChannel: Channel!
defaultAttributeFamily: AttributeFamily!
defaultInventorySource: InventorySource!
}
Channel
🚧 Channel type will be deprecated in the near future.
The notion of the Channel type is that you manage several websites/channels through one dashboard. A company/tenant can have several channels. Each website is a separate channel with its specific sphere of products, for example, clothes, cell phones, and bikes. These represent different channels of one dashboard. Thus, you can manage all these products from one dashboard, but for each channel, set the category it belongs.
Channel includes site default locale, the base currency (the primary currency of the website), and root category ID. You can take locales, default locales, currencies, and inventory sources from the channel type.
The following code block represents the Channel type.
type Channel {
id: ID!
code: String!
name: String!
description: String
theme: String!
homePageContent: String
footerContent: String
hostname: String
defaultLocaleId: ID!
baseCurrencyId: ID!
rootCategoryId: ID!
homeSeo: String!
locales: [Locale!]!
defaultLocale: Locale!
currencies: [Currency!]!
inventorySources: [InventorySource!]!
baseCurrency: Currency!
rootCategory: Category!
logoUrl: String
faviconUrl: String
companyId: ID!
company: Tenant!
}
Inventory Source
The Inventory Source is the storehouse of your store. Having several inventories makes the product delivery service more flexible. You set the quantity of the products in each inventory during the creation of the physical product. Thus, in the delivery process, you will track the number of products and from which inventory to deliver the product.
It includes information about the inventory, such as name, email, country, state, postcode, status, etc., and coordinates latitude and longitude.
The following code block represents the Inventory Source type.
type InventorySource {
id: ID!
code: String!
name: String!
description: String
contactName: String!
contactEmail: String!
contactNumber: String!
contactFax: String
country: String!
state: String!
city: String!
street: String!
postcode: String!
priority: Int
default: Boolean!
latitude: String
longitude: String
status: Boolean!
company: Tenant!
totalQty: Int!
}
Locale
Locales define the number of languages on your website. When creating a product, you must fill in the product info on the default locale/language. Afterward, per need, you can fill in translations for that product for all the locales that you have. But before the steps mentioned above, you need to be able to create locales. So, Ucraft Next's API allows you to create various locales/languages, for example, Russian, Arabian, Chinese, etc.
To conclude, you can add any language to the website; however, during the product creation flow, you must fill in the product data on the default locale/language.
You can get Locales from the globalConfigurations
query, which you will need while creating a product.
The following code block represents the Locale type.
type Locale {
id: ID!
name: String!
code: String!
builderLanguageId: ID!
internationalCode: String!
country: String!
direction: String!
isDefault: Boolean!
createdAt: DateTime!
updatedAt: DateTime!
companyId: ID!
company: Tenant!
success: String
mediaIcon: MediaItem
}
Products
Below are described the products in Ucraft Next.
Simple Product
Any physical product for which inventory is recorded is considered a Simple Product. Simple Products include real assets to sell and ship to clients with a single Stock Keeping Unit (SKU). You can use product choices, SKUs, pictures, and specs to characterize the products better.
Simple Products represent a product with a description purely. They can be not only usual products but also a variant of a Configurable Product.
The code block of the Simple Product (GraphQL).
type SimpleProduct {
# ... inherits from ProductTypeInterface
# Type-specific properties
""" The number of stock per inventory. """
inventories: [Inventory!]!
""" The number of the inventories. """
inventoriesCount: Int!
""" The total quantity of the product including all inventories. """
inventoriesTotalQty: Int!
""" If the product is variant, this is the parent configurable product id. """
parentId: ID
""" If the product is variant, this is the parent configurable product. """
parent: ConfigurableProduct
}
Refer here for the Simple Product creation and Update.
Configurable Product
A Configurable Product is a product with many variants based on lists of options for each variant. Each alternative is a separate Simple Product with a unique SKU, which makes it possible to track inventory for each product variant.
If the product is Configurable, it includes types you define as variants. Variants are generated due to attributes.
📘 Variant generating attributes for the product are called super attributes.
As a Configurable Product, the example may be an X Phone with its variants based on RAM Size and color value. So, the Configurable Product is the X Phone, and the variants are two types of sizes (4GB and 8GB) and color values (black and white). Each option value combination for a product is a variant for that product. When you choose 8GB black X Phone, you select the variant (8GB, black) of the product (X Phone). In this instance, if your Simple Product is considered a variant, it has a parent ID, the X Phone ID.
By default, each variant's product name and SKU are determined by the attribute value and either the parent product name or SKU.
The code block of the Configurable Product (GraphQL).
type ConfigurableProduct {
# ... inherits from ProductTypeInterface
# Type-specific properties
""" The variants of the configurable product. """
variants: [SimpleProduct]
""" The count of the variants. """
variantsCount: Int!
""" The attributes which are being participated during the variants generation process. """
superAttributes: [SuperAttribute!]
""" The count of the stock for each inventory. """
inventories: [Inventory!]!
""" The count of the inventories. """
inventoriesCount: Int!
""" The total quantity of the variants in all inventories. """
inventoriesTotalQty: Int!
}
Refer here for the Configurable Product creation and update.
Downloadable Product
Anything you can deliver as a file is a Downloadable Product, such as a video, software application, or audio file. You may sell an album as a whole or sell each song separately. Once a successful purchase, clients receive a link to download a file.
But before making a purchase, here is a need for a sample of the Downloadable Product. The sample is the pre-demo or the short description of the actual product.
An example of a sample can be an excerpt from a book, film, or a trailer from a learning course that the customer can try before buying the actual product.
The code block of the Downloadable Product (GraphQL).
type DownloadableProduct {
# ... inherits from ProductTypeInterface
# Type-specific properties
""" The sample version of the downloadable links. """
downloadableSamples: [ProductDownloadableSample!]
""" The links of the downloadable files. """
downloadableLinks: [ProductDownloadableLink!]
}
Refer here for the Downloadable Product creation and update.
Subscription Product
Subscription Products are considered to be physical or online goods and services that require a client to pay a recurring fee at regular periods for access to a product. Such products are focused on services based on the exact regular payment recurrence.
Thus, this business model allows you to develop goods with recurring payments. For example, monthly product types, weekly service memberships, etc.
The code block of the Subscription Product (GraphQL).
type SubscriptionProduct {
# ... inherits from ProductTypeInterface
# Type-specific properties
""" The subscription plans of the product. """
subscriptionPlans: [ProductSubscriptionPlan!]!
}
Refer here for the Subscription Product creation and update.
Global Configurations Query
Query to get Global Configurations such as (default channel, company, default inventory source, default attribute family, default locale, and so on).
You will need the response data of this query during the product creation/update.
query globalConfigurations {
globalConfigurations {
company {
defaultAttributeFamily {
id
}
defaultInventorySource {
id
}
defaultChannel {
defaultLocale {
code
}
name
code
id
baseCurrency {
code
id
name
symbol
}
}
}
coreConfigs {
code
value
id
}
importBlueprintUrls {
category
product
}
}
}
Query Structure
With the argument of products input, the specification goes for the page size, and with the page argument, the specification goes for the page number.
To get the product's main data, you must specify fields under the ProductTypeInterface
segment. The custom usage is the following.
The common fields for all types of products are id
, attributeValues
, mediaImages
, categories
, and relatedProducts
, simple products: inventories total quantity
, and Configurable Products: variants
.
Product Queries
You may acquire products by using the Products Query. The GraphQL query is displayed in the following code block.
query {
products(first: 10 page: 1) {
data{
... on ProductTypeInterface {
id
attributeValues {
attributeCode
value
}
mediaImages {
mediaId
}
categories {
id
name
metaTitle
}
relatedProducts {
... on ProductTypeInterface {
id
}
}
... on SimpleProduct {
inventoriesTotalQty
}
... on ConfigurableProduct {
variants {
id
attributeValues {
attributeCode
value
}
}
}
... on DownloadableProduct {
downloadableLinks {
id
title
price
url
}
}
... on SubscriptionProduct {
subscriptionPlans {
title
type
price
}
}
}
}
}
}
You get products by product ID. In the Product Query input, provide the product id.
Observe the following GraphQL query code block:
query {
product(id: 1) {
... on ProductTypeInterface {
id
attributeValues {
attributeCode
value
}
mediaImages {
mediaId
}
categories {
id
name
metaTitle
}
relatedProducts {
... on ProductTypeInterface {
id
}
}
... on SimpleProduct {
inventoriesTotalQty
}
... on ConfigurableProduct {
variants {
id
attributeValues {
attributeCode
value
}
}
}
... on DownloadableProduct {
downloadableLinks {
id
title
price
url
}
}
... on SubscriptionProduct {
subscriptionPlans {
title
type
price
}
}
}
}
}
Slug
A Slug is a web address's unique identifier. It is the URL key of the product. You may want to generate and use slugs mainly for SEO purposes. With slugs that contain title keywords, search engines can better identify and rank content. Since the product slug must be unique, a separate query is run when generating a slug.
The following query generates a product's unique Slug. If the generated slug already exists, it will attach a certain hash on the right side like iphone-x-128-gb-red-fe2ba2.
query {
generateProductUniqueSlug(name: "iphone x 128 gb red")
}
Success Response (JSON):
{
"data": {
"generateProductUniqueSlug": "iphone-x-128-gb-red"
}
}
SKU
SKU refers to a unique identifier or code. It is used to distinguish products and keep track of products. SKU numbers are issued to products depending on several factors such as price, color, type, size, and so on.
If your product has several variants, you must also generate a unique SKU for each variation to track performance.
The following query generates a product's unique SKU. If the generated SKU already exists, it will attach a certain hash on the right side like iphone-x-128-gb-red-fe2ba2.
query {
generateProductUniqueSku(name: "iphone x 128 gb red")
}
Success Response (JSON):
{
"data": {
"generateProductUniqueSku": "iphone-x-128-gb-red"
}
}
Product Mutations
Simple Product Creation and Update
The following code block displays a Simple Product creation (GraphQL):
Mutation/ Create Simple product
mutation createSimpleProduct($input: SimpleProductInput!) {
createSimpleProduct(input: $input) {
id
attributeValues {
id
attributeCode
value
}
inventories {
id
qty
}
categories {
id
name
slug
}
inventoriesTotalQty
mediaImages {
mediaId
mediaType
default
}
}
}
Query Variables
{
"input": {
"categories": [
"8",
"9",
"10",
"11"
],
"sku": "iphone-x-128gb-red",
"inventories": [
{
"inventorySourceId": "2",
"qty": 123
}
],
"mediaImages": [],
"attributeFamilyId": "4",
"channel": "[email protected]",
"channels": [
"2"
],
"attributes": [
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X 128GB RED"
}
]
},
{
"code": "meta_title",
"translations": []
},
{
"code": "meta_description",
"translations": []
},
{
"code": "description",
"translations": [
{
"locale": "en",
"value": "<p>The newest Iphone </p>"
}
]
},
{
"code": "url_key",
"translations": [
{
"locale": "en",
"value": "iphone-x-128gb-red"
}
]
},
{
"code": "price",
"value": "123"
},
{
"code": "weight",
"value": "0.4"
},
{
"code": "visible_individually",
"value": true
},
{
"code": "guest_checkout",
"value": 1
},
{
"code": "sku",
"value": "iphone-x-128gb-red"
},
{
"code": "status",
"value": 1
}
]
}
}
The following code block displays a Simple Product update (GraphQL):
Mutation/ Update Simple product
mutation updateSimpleProduct($id: ID!, $input: SimpleProductInput!) {
updateSimpleProduct(id: $id, input: $input) {
id
attributeValues {
id
attributeCode
value
}
inventories {
id
qty
}
inventoriesTotalQty
categories {
id
name
slug
}
mediaImages {
mediaId
mediaType
default
}
}
}
Query Variables
{
"id": "19",
"input": {
"categories": [
"8",
"9",
"10",
"11"
],
"crossSells": [],
"relatedProducts": [],
"sku": "iphone-x-128gb-red",
"upSells": [],
"inventories": [
{
"inventorySourceId": "2",
"qty": 123
}
],
"mediaImages": [],
"attributeFamilyId": "4",
"channel": "[email protected]",
"channels": [
"2"
],
"attributes": [
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X 128GB RED"
}
]
},
{
"code": "meta_title",
"translations": []
},
{
"code": "meta_description",
"translations": []
},
{
"code": "description",
"translations": [
{
"locale": "en",
"value": "<p>The newest Iphone UPDATED</p>"
}
]
},
{
"code": "url_key",
"translations": [
{
"locale": "en",
"value": "iphone-x-128gb-red"
}
]
},
{
"code": "price",
"value": "12"
},
{
"code": "weight",
"value": "0.4"
},
{
"code": "visible_individually",
"value": true
},
{
"code": "guest_checkout",
"value": 1
},
{
"code": "sku",
"value": "iphone-x-128gb-red"
},
{
"code": "status",
"value": 1
}
]
}
}
Configurable Product Creation and Update
The following code block displays a Configurable Product creation (GraphQL):
Mutation/ Create Configurable Product
mutation createConfigurableProduct($input: ConfigurableProductInput!) {
createConfigurableProduct(input: $input) {
...ProductFragment
variants {
...ProductFragment
inventories {
id
qty
productId
inventorySourceId
inventorySource {
id
code
name
}
}
}
variantsCount
superAttributes {
id
}
inventoriesTotalQty
}
}
fragment ProductFragment on ProductTypeInterface {
id
attributeValues {
id
attributeCode
value
}
attributeOptions {
id
adminName
label
swatchValue
sortOrder
attributeId
translations {
id
locale
label
attributeOptionId
}
}
categories {
id
name
slug
}
mediaImages {
id
mediaId
mediaType
default
}
}
Query Variables
{
"input": {
"sku": "iphone-x",
"inventories": [
{
"inventorySourceId": "1",
"qty": 123
}
],
"mediaImages": [],
"attributeFamilyId": "1",
"channel": "[email protected]",
"channels": [
"1"
],
"attributes": [
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "meta_title",
"translations": []
},
{
"code": "meta_description",
"translations": []
},
{
"code": "description",
"translations": [
{
"locale": "en",
"value": "<p>Qwert</p>"
}
]
},
{
"code": "url_key",
"translations": [
{
"locale": "en",
"value": "iphone-x"
}
]
},
{
"code": "price",
"value": "1000"
},
{
"code": "weight",
"value": "0.3"
},
{
"code": "visible_individually",
"value": true
},
{
"code": "guest_checkout",
"value": 1
},
{
"code": "sku",
"value": "iphone-x"
},
{
"code": "status",
"value": 1
}
],
"variants": [
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-red-4gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "4"
},
{
"code": "ram",
"value": "6"
}
],
"sku": "iphone-x-red-4gb"
},
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-red-8gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "4"
},
{
"code": "ram",
"value": "7"
}
],
"sku": "iphone-x-red-8gb"
},
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-space gray-4gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "5"
},
{
"code": "ram",
"value": "6"
}
],
"sku": "iphone-x-space gray-4gb"
},
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-space gray-8gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "5"
},
{
"code": "ram",
"value": "7"
}
],
"sku": "iphone-x-space gray-8gb"
}
],
"superAttributes": [
{
"attributeCode": "color",
"values": [
"4",
"5"
]
},
{
"attributeCode": "ram",
"values": [
"6",
"7"
]
}
]
}
}
The following code block displays a Configurable Product update (GraphQL):
Mutation/ Update Configurable Product
mutation updateConfigurableProduct($id: ID!, $input: ConfigurableProductInput!) {
updateConfigurableProduct(id: $id, input: $input) {
...ProductFragment
id
attributeFamilyId
sku
type
inventoriesTotalQty
inventories {
id
qty
inventorySourceId
}
mediaImages {
id
mediaId
mediaType
default
}
superAttributes {
id
code
adminName
options {
id
adminName
translations {
id
locale
label
attributeOptionId
}
}
}
attributeValues {
value
attribute {
type
}
productId
attributeCode
}
categories {
id
name
}
variants {
id
type
sku
attributeValues {
value
attribute {
type
}
attributeCode
}
mediaImages {
default
id
mediaId
}
inventories {
id
inventorySourceId
qty
}
}
}
}
fragment ProductFragment on ProductTypeInterface {
id
type
attributeFamilyId
sku
attributeValues {
id
attributeCode
value
productId
attributeId
locale
textValue
booleanValue
integerValue
floatValue
dateTimeValue
dateValue
jsonValue
}
attributeOptions {
id
adminName
label
swatchValue
sortOrder
attributeId
translations {
id
locale
label
attributeOptionId
}
}
categories {
id
name
slug
}
mediaImages {
id
mediaId
mediaType
default
}
}
Query Variables
{
"id": "10",
"input": {
"categories": [],
"crossSells": [],
"relatedProducts": [],
"sku": "iphone-x",
"upSells": [],
"inventories": [
{
"inventorySourceId": "1",
"qty": 123
}
],
"mediaImages": [],
"attributeFamilyId": "1",
"channel": "[email protected]",
"channels": [
"1"
],
"attributes": [
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "meta_title",
"translations": []
},
{
"code": "meta_description",
"translations": []
},
{
"code": "description",
"translations": [
{
"locale": "en",
"value": "<p>Qwert UPDATED</p>"
}
]
},
{
"code": "url_key",
"translations": [
{
"locale": "en",
"value": "iphone-x"
}
]
},
{
"code": "price",
"value": 1000
},
{
"code": "weight",
"value": "0.3"
},
{
"code": "visible_individually",
"value": true
},
{
"code": "guest_checkout",
"value": 1
},
{
"code": "sku",
"value": "iphone-x"
},
{
"code": "status",
"value": 1
}
],
"variants": [
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-red-4gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "4"
},
{
"code": "ram",
"value": "6"
}
],
"sku": "iphone-x-red-4gb"
},
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-red-8gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "5"
},
{
"code": "ram",
"value": "6"
}
],
"sku": "iphone-x-red-8gb"
},
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-space gray-4gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "4"
},
{
"code": "ram",
"value": "7"
}
],
"sku": "iphone-x-space gray-4gb"
},
{
"mediaImages": [],
"inventories": [
{
"inventorySourceId": 1,
"qty": 123
}
],
"attributes": [
{
"code": "price",
"value": 1000
},
{
"code": "special_price",
"value": 0
},
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Iphone X"
}
]
},
{
"code": "sku",
"value": "iphone-x-space gray-8gb"
},
{
"code": "status",
"value": true
},
{
"code": "color",
"value": "5"
},
{
"code": "ram",
"value": "7"
}
],
"sku": "iphone-x-space gray-8gb"
}
],
"superAttributes": [
{
"attributeCode": "color",
"values": [
"4",
"5"
]
},
{
"attributeCode": "ram",
"values": [
"6",
"7"
]
}
]
}
}
Downloadable Product Creation and Update
The following code block displays a Downloadable Product creation (GraphQL):
Mutation/ Create Downloadable Product
mutation createDownloadableProduct($input: DownloadableProductInput!) {
createDownloadableProduct(input: $input) {
...ProductFragment
downloadableSamples {
id
url
file
fileName
type
sortOrder
productId
createdAt
updatedAt
translations {
id
locale
title
productDownloadableSampleId
}
}
downloadableLinks {
id
title
price
url
file
fileName
type
sampleUrl
sampleFile
sampleFileName
sampleType
sortOrder
productId
downloads
translations {
id
locale
title
productDownloadableLinkId
}
}
}
}
fragment ProductFragment on ProductTypeInterface {
id
type
attributeFamilyId
sku
attributeValues {
id
attributeCode
value
productId
attributeId
locale
textValue
booleanValue
integerValue
floatValue
dateTimeValue
dateValue
jsonValue
}
attributeOptions {
id
adminName
label
swatchValue
sortOrder
attributeId
translations {
id
locale
label
attributeOptionId
}
}
categories {
id
name
slug
}
mediaImages {
id
mediaId
mediaType
default
}
}
Query Variables
{
"input": {
"sku": "marvel-avengers-movie",
"mediaImages": [],
"attributeFamilyId": "2",
"channel": "[email protected]",
"channels": [
"1"
],
"attributes": [
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Marvel Avengers Movie"
}
]
},
{
"code": "meta_title",
"translations": []
},
{
"code": "meta_description",
"translations": []
},
{
"code": "description",
"translations": [
{
"locale": "en",
"value": "<p>The Avengers</p>"
}
]
},
{
"code": "url_key",
"translations": [
{
"locale": "en",
"value": "marvel-avengers-movie"
}
]
},
{
"code": "price",
"value": "7"
},
{
"code": "visible_individually",
"value": true
},
{
"code": "guest_checkout",
"value": 1
},
{
"code": "sku",
"value": "marvel-avengers-movie"
},
{
"code": "status",
"value": 1
}
],
"downloadableLinks": [
{
"translations": [
{
"title": "1080p",
"locale": "en"
}
],
"price": 7,
"comparedAtPrice": null,
"type": "URL",
"url": "https://google.com",
"sortOrder": 0,
"downloads": 9999
},
{
"translations": [
{
"title": "4K",
"locale": "en"
}
],
"price": 10,
"comparedAtPrice": null,
"type": "URL",
"url": "https://google.com",
"sortOrder": 1,
"downloads": 9999
}
],
"downloadableSamples": [
{
"translations": [
{
"title": "1080p trailer",
"locale": "en"
}
],
"type": "URL",
"url": "https://youtube.com",
"sortOrder": 0
},
{
"translations": [
{
"title": "4K trailer",
"locale": "en"
}
],
"type": "URL",
"url": "https://youtube.com",
"sortOrder": 1
}
]
}
}
The following code block displays a Downloadable Product update (GraphQL):
Mutation/ Update Downloadable Product
mutation updateDownloadableProduct($id: ID!, $input: DownloadableProductInput!) {
updateDownloadableProduct(id: $id, input: $input) {
type
sku
id
attributeFamilyId
downloadableSamples {
fileName
url
id
file
translations {
locale
title
}
type
sortOrder
}
downloadableLinks {
url
id
fileName
file
translations {
locale
title
}
price
type
sortOrder
}
mediaImages {
id
mediaId
mediaType
default
}
attributeValues {
value
attribute {
type
}
productId
attributeCode
}
categories {
id
name
}
attributeOptions {
sortOrder
attributeId
translations {
id
locale
}
}
}
}
Query Variables
{
"id": "19",
"input": {
"categories": [],
"crossSells": [],
"relatedProducts": [],
"sku": "marvel-avengers-movie",
"upSells": [],
"mediaImages": [],
"downloadableLinks": [
{
"url": "https://google.com",
"fileName": null,
"file": null,
"translations": [
{
"title": "1080p",
"locale": "en"
}
],
"price": 7,
"comparedAtPrice": null,
"type": "URL",
"sortOrder": 0,
"downloads": 9999
},
{
"url": "https://google.com",
"fileName": null,
"file": null,
"translations": [
{
"title": "4K",
"locale": "en"
}
],
"price": 10,
"comparedAtPrice": null,
"type": "URL",
"sortOrder": 1,
"downloads": 9999
}
],
"downloadableSamples": [
{
"fileName": null,
"url": "https://youtube.com",
"file": null,
"translations": [
{
"title": "1080p trailer",
"locale": "en"
}
],
"type": "URL",
"sortOrder": 0
},
{
"fileName": null,
"url": "https://youtube.com",
"file": null,
"translations": [
{
"title": "4K trailer",
"locale": "en"
}
],
"type": "URL",
"sortOrder": 1
}
],
"attributeFamilyId": "2",
"channel": "[email protected]",
"channels": [
"1"
],
"attributes": [
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "Marvel Avengers Movie"
}
]
},
{
"code": "meta_title",
"translations": []
},
{
"code": "meta_description",
"translations": []
},
{
"code": "description",
"translations": [
{
"locale": "en",
"value": "<p>The Avengers UPDATED</p>"
}
]
},
{
"code": "url_key",
"translations": [
{
"locale": "en",
"value": "marvel-avengers-movie"
}
]
},
{
"code": "price",
"value": 7
},
{
"code": "visible_individually",
"value": true
},
{
"code": "guest_checkout",
"value": 1
},
{
"code": "sku",
"value": "marvel-avengers-movie"
},
{
"code": "status",
"value": 1
}
]
}
}
Subscription Product Creation and Update
The following code block displays a Subscription Product creation (GraphQL):
Mutation/ Create Subscription Product
mutation createSubscriptionProduct($input: SubscriptionProductInput!) {
createSubscriptionProduct(input: $input) {
id
}
}
Query Variables
{
"input": {
"sku": "1660036663693",
"mediaImages": [],
"attributeFamilyId": "3",
"channel": "[email protected]",
"channels": [
"1"
],
"attributes": [
{
"code": "name",
"translations": [
{
"locale": "en",
"value": "English course"
}
]
},
{
"code": "meta_title",
"translations": []
},
{
"code": "meta_description",
"translations": []
},
{
"code": "description",
"translations": [
{
"locale": "en",
"value": "<p>English course with 7 days trial.</p>"
}
]
},
{
"code": "url_key",
"translations": [
{
"locale": "en",
"value": "english-course"
}
]
},
{
"code": "visible_individually",
"value": true
},
{
"code": "guest_checkout",
"value": 1
},
{
"code": "trial_days",
"value": "7"
},
{
"code": "status",
"value": 1
},
{
"code": "sku",
"value": "1660036663693"
}
],
"subscriptionPlans": [
{
"type": "MONTHLY",
"title": "Monthly plan",
"price": 10,
"description": "<p>Monthly plan description</p>"
},
{
"type": "YEARLY",
"title": "Yearly plan",
"price": 180,
"description": "<p>Yearly plan description</p>"
}
]
}
}
The following code block displays a Subscription Product update (GraphQL):
Mutation/ Update Subscription Product
mutation updateSubscriptionProduct($input: SubscriptionProductInput!, $id: ID!) {
updateSubscriptionProduct(input: $input, id: $id) {
id
attributeFamilyId
sku
type
mediaImages {
id
mediaId
mediaType
default
}
attributeValues {
value
attribute {
type
}
productId
attributeCode
}
categories {
id
name
}
attributeOptions {
sortOrder
attributeId
translations {
id
locale
}
}
subscriptionPlans {
id
type
title
description
price
comparedAtPrice
}
}
}
Product Deletion
The following code block displays a product deletion (GraphQL):
Mutation/ Delete product
mutation deleteProduct($id: ID!) {
deleteProduct(id: $id)
}
Query Variables
{
"id": "20"
}