Some thoughts and practices for migrating from REST to GraphQL (creating resources), refer to Shopify
1. Add Template to create a template. as shown in Figure 1
2. Click the save button to view the network request. Request URL:https://xxx.myshopify.com/admin/themes/111/assets. Request method: POST. This is the REST implementation. as shown in Figure 2
Requested form data:
asset[key]: templates/article.dawn2.json
asset[value]: {
"sections": {
"main": {
"type": "main-article",
"blocks": {
"featured_image": {
"type": "featured_image",
"settings": {
}
},
"title": {
"type": "title",
"settings": {
}
},
"content": {
"type": "content",
"settings": {
}
},
"share": {
"type": "share",
"settings": {
}
}
},
"block_order": [
"featured_image",
"title",
"share",
"content"
],
"settings": {
}
}
},
"order": [
"main"
]
}
Response data:
{
"asset": {
"key": "templates\/article.dawn2.json",
"public_url": null,
"created_at": "2022-02-22T22:23:17-08:00",
"updated_at": "2022-02-22T22:23:17-08:00",
"content_type": "application\/json",
"size": 324,
"checksum": "125d46765a7b7f96e7f3992a8bcfe22e",
"theme_id": 128094896334
}
}
3. The API for creating template files is not implemented in GraphQL. Decided to refer to productCreate ( input productInput!, media[CreateMediaInput!]) productCreatePayload creates a product. as shown in Figure 3
4. Test request and response structure, first test the structure of response failure. as shown in Figure 4
Request data:
mutation {
productCreate(
input: {title: "title"} {
... product
... userErrors
}
}
fragment product on ProductCreatePayload {
product {
status
storefrontId
tags
templateSuffix
title
totalInventory
totalVariants
tracksInventory
}
}
fragment userErrors on ProductCreatePayload {
userErrors {
field
message
}
}
Response data:
{
"errors": [
{
"message": "Parse error on \"{\" (LCURLY) at [3, 29]",
"locations": [
{
"line": 3,
"column": 29
}
]
}
]
}
5. Test request and response structure, test the structure of the response to success. But the response failed. as shown in Figure 5
Request data:
mutation {
productCreate(
input: {
title: "标题 20220223 2",
}
) {
product {
... product
... userErrors
}
}
fragment product on ProductCreatePayload {
product {
title
}
}
fragment userErrors on ProductCreatePayload {
userErrors {
field
message
}
}
Response data:
{
"errors": [
{
"message": "Unexpected end of document",
"locations": []
}
]
}
6. Decided to manually add a product in the Shopify background, check the network request, which is the GraphQL API of the request, refer to its request parameters, and copy it to Altair’s request. Click to select Query, and then right-click to copy the value. as shown in Figure 6
7. Paste it into Altair’s query. as shown in Figure 7
mutation CreateProduct($product: ProductInput!, $media: [CreateMediaInput!]) {
productCreate(input: $product, media: $media) {
product {
id
title
handle
descriptionHtml
resourceAlerts {
content
dismissed
dismissibleHandle
severity
title
actions {
primary
title
url
__typename
}
__typename
}
firstVariant: variants(first: 1) {
edges {
node {
id
requiresShipping
weight
weightUnit
barcode
sku
inventoryPolicy
fulfillmentService {
id
__typename
}
inventoryItem {
id
unitCost {
amount
__typename
}
countryCodeOfOrigin
provinceCodeOfOrigin
harmonizedSystemCode
tracked
__typename
}
...PricingCardVariant
__typename
}
__typename
}
__typename
}
...SEOCardProduct
...StandardProductType
...CustomProductType
__typename
}
userErrors {
field
message
__typename
}
__typename
}
}
fragment PricingCardVariant on ProductVariant {
id
price
compareAtPrice
taxable
taxCode
presentmentPrices(first: 2) {
edges {
node {
price {
amount
__typename
}
__typename
}
__typename
}
__typename
}
showUnitPrice
unitPriceMeasurement {
quantityValue
quantityUnit
referenceValue
referenceUnit
__typename
}
__typename
}
fragment SEOCardProduct on Product {
seo {
title
description
__typename
}
__typename
}
fragment StandardProductType on Product {
standardProductType {
productTaxonomyNodeId
parentProductTaxonomyNodeId
name
fullName
isLeaf
isRoot
__typename
}
inferredProductMetadata {
standardProductType {
productTaxonomyNodeId
parentProductTaxonomyNodeId
name
fullName
isLeaf
isRoot
__typename
}
__typename
}
__typename
}
fragment CustomProductType on Product {
customProductType
__typename
}
8. Click to select Variables, and then right-click to copy the value. as shown in Figure 8
9. Paste it into the variable of Altair. as shown in Figure 9
{
"media": null,
"product": {
"standardProductType": null,
"customProductType": null,
"title": "标题 20220223 1",
"descriptionHtml": "",
"handle": "",
"seo": {
"title": "",
"description": ""
},
"status": "DRAFT",
"variants": [
{
"compareAtPrice": null,
"price": "0",
"taxable": true,
"inventoryItem": {
"cost": null,
"countryCodeOfOrigin": null,
"provinceCodeOfOrigin": null,
"harmonizedSystemCode": null,
"tracked": true
},
"requiresShipping": true,
"weight": 0,
"weightUnit": "KILOGRAMS",
"fulfillmentServiceId": "gid://shopify/FulfillmentService/manual",
"sku": "",
"barcode": "",
"inventoryPolicy": "DENY",
"showUnitPrice": false,
"unitPriceMeasurement": {
"quantityValue": 0,
"quantityUnit": null,
"referenceValue": 0,
"referenceUnit": null
},
"taxCode": null,
"inventoryQuantities": [
{
"availableQuantity": 0,
"locationId": "gid://shopify/Location/66268496078"
}
],
"options": [
"Default Title"
]
}
],
"images": [],
"tags": [],
"templateSuffix": "",
"giftCardTemplateSuffix": "",
"vendor": "",
"giftCard": false,
"collectionsToJoin": [],
"workflow": "product-details-create",
"metafields": []
}
}
10. Send request error, response: fieldResourceAlertsdoesn’tT EXIST ON TYPEproduct. Delete the query in sequence: ResourceAlerts, ShowUnitPrice, UnitPriceMeasurement, StandardProductType. As shown in Figure 10
{
"errors": [
{
"message": "Field 'resourceAlerts' doesn't exist on type 'Product'",
"locations": [
{
"line": 8,
"column": 7
}
],
"path": [
"mutation CreateProduct",
"productCreate",
"product",
"resourceAlerts"
],
"extensions": {
"code": "undefinedField",
"typeName": "Product",
"fieldName": "resourceAlerts"
}
},
{
"message": "Field 'showUnitPrice' doesn't exist on type 'ProductVariant'",
"locations": [
{
"line": 88,
"column": 3
}
],
"path": [
"fragment PricingCardVariant",
"showUnitPrice"
],
"extensions": {
"code": "undefinedField",
"typeName": "ProductVariant",
"fieldName": "showUnitPrice"
}
},
{
"message": "Field 'unitPriceMeasurement' doesn't exist on type 'ProductVariant'",
"locations": [
{
"line": 89,
"column": 3
}
],
"path": [
"fragment PricingCardVariant",
"unitPriceMeasurement"
],
"extensions": {
"code": "undefinedField",
"typeName": "ProductVariant",
"fieldName": "unitPriceMeasurement"
}
},
{
"message": "Field 'standardProductType' doesn't exist on type 'Product'",
"locations": [
{
"line": 109,
"column": 3
}
],
"path": [
"fragment StandardProductType",
"standardProductType"
],
"extensions": {
"code": "undefinedField",
"typeName": "Product",
"fieldName": "standardProductType"
}
},
{
"message": "Field 'inferredProductMetadata' doesn't exist on type 'Product'",
"locations": [
{
"line": 118,
"column": 3
}
],
"path": [
"fragment StandardProductType",
"inferredProductMetadata"
],
"extensions": {
"code": "undefinedField",
"typeName": "Product",
"fieldName": "inferredProductMetadata"
}
}
]
}
11. Send request error, response: variable $product of type productInput! was provided invalid value for standardProductType (field is not defined on productInput), variables.0.InventoryItem.CountryCodeOforigin (Field is not defined on InventoryItemInput), variables.0.InventoryItem.ProvinceCodeOfOrigin (Field is not defined on InventoryItemInput), Variants.0.InventoryItem.HarmonizedSystemCode (Field is not defined on productVariantinput), variables.0.UnitPriceMeasurement (Field is not defined on) productVariantinput), workflow (Field is not defined on productInput). Delete the variables in turn: standardProductType, variables.0.inventoryItem.coun trycodeoforigin, variables.0.InventoryItem.ProvinceCodeOFori GIN, Variants.0.InventoryItem.HarmonizedSystemCode, Variants .0.ShowUnitPrice, Variants.0.UnitPriceMeasurement, workflow. as shown in Figure 11
{
"errors": [
{
"message": "Variable $product of type ProductInput! was provided invalid value for standardProductType (Field is not defined on ProductInput), variants.0.inventoryItem.countryCodeOfOrigin (Field is not defined on InventoryItemInput), variants.0.inventoryItem.provinceCodeOfOrigin (Field is not defined on InventoryItemInput), variants.0.inventoryItem.harmonizedSystemCode (Field is not defined on InventoryItemInput), variants.0.showUnitPrice (Field is not defined on ProductVariantInput), variants.0.unitPriceMeasurement (Field is not defined on ProductVariantInput), workflow (Field is not defined on ProductInput)",
"locations": [
{
"line": 1,
"column": 24
}
],
"extensions": {
"value": {
"standardProductType": null,
"customProductType": null,
"title": "标题 20220223 3",
"descriptionHtml": "",
"handle": "",
"seo": {
"title": "",
"description": ""
},
"status": "DRAFT",
"variants": [
{
"compareAtPrice": null,
"price": "0",
"taxable": true,
"inventoryItem": {
"cost": null,
"countryCodeOfOrigin": null,
"provinceCodeOfOrigin": null,
"harmonizedSystemCode": null,
"tracked": true
},
"requiresShipping": true,
"weight": 0,
"weightUnit": "KILOGRAMS",
"fulfillmentServiceId": "gid://shopify/FulfillmentService/manual",
"sku": "",
"barcode": "",
"inventoryPolicy": "DENY",
"showUnitPrice": false,
"unitPriceMeasurement": {
"quantityValue": 0,
"quantityUnit": null,
"referenceValue": 0,
"referenceUnit": null
},
"taxCode": null,
"inventoryQuantities": [
{
"availableQuantity": 0,
"locationId": "gid://shopify/Location/66268496078"
}
],
"options": [
"Default Title"
]
}
],
"images": [],
"tags": [],
"templateSuffix": "",
"giftCardTemplateSuffix": "",
"vendor": "",
"giftCard": false,
"collectionsToJoin": [],
"workflow": "product-details-create",
"metafields": []
},
"problems": [
{
"path": [
"standardProductType"
],
"explanation": "Field is not defined on ProductInput"
},
{
"path": [
"variants",
0,
"inventoryItem",
"countryCodeOfOrigin"
],
"explanation": "Field is not defined on InventoryItemInput"
},
{
"path": [
"variants",
0,
"inventoryItem",
"provinceCodeOfOrigin"
],
"explanation": "Field is not defined on InventoryItemInput"
},
{
"path": [
"variants",
0,
"inventoryItem",
"harmonizedSystemCode"
],
"explanation": "Field is not defined on InventoryItemInput"
},
{
"path": [
"variants",
0,
"showUnitPrice"
],
"explanation": "Field is not defined on ProductVariantInput"
},
{
"path": [
"variants",
0,
"unitPriceMeasurement"
],
"explanation": "Field is not defined on ProductVariantInput"
},
{
"path": [
"workflow"
],
"explanation": "Field is not defined on ProductInput"
}
]
}
}
]
}
12. Create a product successfully. Response 200. as shown in Figure 12
Request query:
mutation CreateProduct($product: ProductInput!, $media: [CreateMediaInput!]) {
productCreate(input: $product, media: $media) {
product {
id
title
handle
descriptionHtml
firstVariant: variants(first: 1) {
edges {
node {
id
requiresShipping
weight
weightUnit
barcode
sku
inventoryPolicy
fulfillmentService {
id
__typename
}
inventoryItem {
id
unitCost {
amount
__typename
}
countryCodeOfOrigin
provinceCodeOfOrigin
harmonizedSystemCode
tracked
__typename
}
...PricingCardVariant
__typename
}
__typename
}
__typename
}
...SEOCardProduct
...CustomProductType
__typename
}
userErrors {
field
message
__typename
}
__typename
}
}
fragment PricingCardVariant on ProductVariant {
id
price
compareAtPrice
taxable
taxCode
presentmentPrices(first: 2) {
edges {
node {
price {
amount
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
fragment SEOCardProduct on Product {
seo {
title
description
__typename
}
__typename
}
fragment CustomProductType on Product {
customProductType
__typename
}
Request variable:
{
"media": null,
"product": {
"customProductType": null,
"title": "标题 20220223 3",
"descriptionHtml": "",
"handle": "",
"seo": {
"title": "",
"description": ""
},
"status": "DRAFT",
"variants": [
{
"compareAtPrice": null,
"price": "0",
"taxable": true,
"inventoryItem": {
"cost": null,
"tracked": true
},
"requiresShipping": true,
"weight": 0,
"weightUnit": "KILOGRAMS",
"fulfillmentServiceId": "gid://shopify/FulfillmentService/manual",
"sku": "",
"barcode": "",
"inventoryPolicy": "DENY",
"taxCode": null,
"inventoryQuantities": [
{
"availableQuantity": 0,
"locationId": "gid://shopify/Location/66268496078"
}
],
"options": [
"Default Title"
]
}
],
"images": [],
"tags": [],
"templateSuffix": "",
"giftCardTemplateSuffix": "",
"vendor": "",
"giftCard": false,
"collectionsToJoin": [],
"metafields": []
}
}
Response:
{
"data": {
"productCreate": {
"product": {
"id": "gid://shopify/Product/6956647317710",
"title": "标题 20220223 3",
"handle": "标题-20220223-3",
"descriptionHtml": "",
"firstVariant": {
"edges": [
{
"node": {
"id": "gid://shopify/ProductVariant/40929372405966",
"requiresShipping": true,
"weight": 0,
"weightUnit": "KILOGRAMS",
"barcode": "",
"sku": "",
"inventoryPolicy": "DENY",
"fulfillmentService": {
"id": "gid://shopify/FulfillmentService/manual",
"__typename": "FulfillmentService"
},
"inventoryItem": {
"id": "gid://shopify/InventoryItem/43021592854734",
"unitCost": null,
"countryCodeOfOrigin": null,
"provinceCodeOfOrigin": null,
"harmonizedSystemCode": null,
"tracked": true,
"__typename": "InventoryItem"
},
"price": "0.00",
"compareAtPrice": null,
"taxable": true,
"taxCode": null,
"presentmentPrices": {
"edges": [
{
"node": {
"price": {
"amount": "0.0",
"__typename": "MoneyV2"
},
"__typename": "ProductVariantPricePair"
},
"__typename": "ProductVariantPricePairEdge"
}
],
"__typename": "ProductVariantPricePairConnection"
},
"__typename": "ProductVariant"
},
"__typename": "ProductVariantEdge"
}
],
"__typename": "ProductVariantConnection"
},
"seo": {
"title": null,
"description": null,
"__typename": "SEO"
},
"__typename": "Product",
"customProductType": null
},
"userErrors": [],
"__typename": "ProductCreatePayload"
}
},
"extensions": {
"cost": {
"requestedQueryCost": 20,
"actualQueryCost": 19,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 981,
"restoreRate": 50
}
}
}
}
13. Why does the Shopify background call to the GraphQL API do not match the latest version of the GraphQL API? It is initially suspected that the version may be caused by the inconsistency of the version. The version that calls the GraphQL API in the Shopify background is not the latest version. The latest version is: 2022-01. The background call is: 2020-07. as shown in Figure 13
14. The structure when the request responds to an error. Figure 14
mutation {
onlineStoreThemeAssetCreate(
input: { themeId: "vogue", content: "string", key: "string" }
) {
themeAsset {
id
themeId
version
content
key
mimeType
category
schema
createdAt
updatedAt
deletable
renameable
updatable
}
}
}
{
"errors": [
{
"debugMessage": "Undefined index: key",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 5,
"column": 5
}
],
"path": [
"onlineStoreThemeAssetCreate",
"themeAsset"
],
"trace": [
{
"file": "E:\\wwwroot\\object\\Modules\\ThemeStore\\Resolver\\OnlineStoreTheme\\ThemeAssetResolver.php",
"line": 15,
"call": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions::handleError(8, 'Undefined index: key', 'E:\\wwwroot\\object\\Modules\\ThemeStore\\Resolver\\OnlineStoreTheme\\ThemeAssetResolver.php', 15, array(5))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\FieldDirective.php",
"line": 52,
"call": "Modules\\ThemeStore\\Resolver\\OnlineStoreTheme\\ThemeAssetResolver::__invoke(array(1), array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\RenameArgsDirective.php",
"line": 33,
"call": "Nuwave\\Lighthouse\\Schema\\Directives\\FieldDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\SpreadDirective.php",
"line": 36,
"call": "Nuwave\\Lighthouse\\Schema\\Directives\\RenameArgsDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\ArgTraversalDirective.php",
"line": 29,
"call": "Nuwave\\Lighthouse\\Schema\\Directives\\SpreadDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Validation\\ValidateDirective.php",
"line": 53,
"call": "Nuwave\\Lighthouse\\Schema\\Directives\\ArgTraversalDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\ArgTraversalDirective.php",
"line": 29,
"call": "Nuwave\\Lighthouse\\Validation\\ValidateDirective::Nuwave\\Lighthouse\\Validation\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\TrimDirective.php",
"line": 56,
"call": "Nuwave\\Lighthouse\\Schema\\Directives\\ArgTraversalDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Factories\\FieldFactory.php",
"line": 99,
"call": "Nuwave\\Lighthouse\\Schema\\Directives\\TrimDirective::Nuwave\\Lighthouse\\Schema\\Directives\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 623,
"call": "Nuwave\\Lighthouse\\Schema\\Factories\\FieldFactory::Nuwave\\Lighthouse\\Schema\\Factories\\{closure}(array(1), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 550,
"call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, array(1), instance of GraphQL\\Type\\Definition\\ResolveInfo)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 1195,
"call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: OnlineStoreThemeAssetCreatePayload, array(1), instance of ArrayObject(1), array(2))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 1145,
"call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: OnlineStoreThemeAssetCreatePayload, array(1), array(1), instance of ArrayObject(1))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 1106,
"call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: OnlineStoreThemeAssetCreatePayload, instance of ArrayObject(1), array(1), array(1))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 793,
"call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: OnlineStoreThemeAssetCreatePayload, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), array(1))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 654,
"call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: OnlineStoreThemeAssetCreatePayload, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), array(1))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 557,
"call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: OnlineStoreThemeAssetCreatePayload, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), array(1))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 474,
"call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: Mutation, null, instance of ArrayObject(1), array(1))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 857,
"call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(array(0), 'onlineStoreThemeAssetCreate')"
},
{
"call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(array(0), 'onlineStoreThemeAssetCreate')"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 859,
"function": "array_reduce(array(1), instance of Closure, array(0))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 490,
"call": "GraphQL\\Executor\\ReferenceExecutor::promiseReduce(array(1), instance of Closure, array(0))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 263,
"call": "GraphQL\\Executor\\ReferenceExecutor::executeFieldsSerially(GraphQLType: Mutation, null, array(0), instance of ArrayObject(1))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\ReferenceExecutor.php",
"line": 215,
"call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation(instance of GraphQL\\Language\\AST\\OperationDefinitionNode, null)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Executor\\Executor.php",
"line": 156,
"call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php",
"line": 162,
"call": "GraphQL\\Executor\\Executor::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php",
"line": 94,
"call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php",
"line": 268,
"call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php",
"line": 203,
"call": "Nuwave\\Lighthouse\\GraphQL::executeParsedQuery(instance of GraphQL\\Language\\AST\\DocumentNode, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php",
"line": 162,
"call": "Nuwave\\Lighthouse\\GraphQL::parseAndExecuteQuery('mutation {\n onlineStoreThemeAssetCreate(\n input: { themeId: \"vogue\", content: \"string\", key: \"string\" }\n ) {\n themeAsset {\n id\n themeId\n version\n content\n key\n mimeType\n category\n schema\n createdAt\n updatedAt\n deletable\n renameable\n updatable\n }\n }\n}', instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php",
"line": 121,
"call": "Nuwave\\Lighthouse\\GraphQL::executeOperation(instance of GraphQL\\Server\\OperationParams, instance of Nuwave\\Lighthouse\\Schema\\Context)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Utils.php",
"line": 99,
"call": "Nuwave\\Lighthouse\\GraphQL::Nuwave\\Lighthouse\\{closure}(instance of GraphQL\\Server\\OperationParams)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php",
"line": 120,
"call": "Nuwave\\Lighthouse\\Support\\Utils::applyEach(instance of Closure, instance of GraphQL\\Server\\OperationParams)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Controllers\\GraphQLController.php",
"line": 32,
"call": "Nuwave\\Lighthouse\\GraphQL::executeOperationOrOperations(instance of GraphQL\\Server\\OperationParams, instance of Nuwave\\Lighthouse\\Schema\\Context)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php",
"line": 48,
"call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::__invoke(instance of Illuminate\\Http\\Request, instance of Nuwave\\Lighthouse\\GraphQL, instance of Illuminate\\Events\\Dispatcher, instance of Laragraph\\Utils\\RequestParser, instance of Nuwave\\Lighthouse\\Execution\\SingleResponse, instance of Nuwave\\Lighthouse\\Execution\\ContextFactory)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 219,
"call": "Illuminate\\Routing\\ControllerDispatcher::dispatch(instance of Illuminate\\Routing\\Route, instance of Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController, '__invoke')"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 176,
"call": "Illuminate\\Routing\\Route::runController()"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 681,
"call": "Illuminate\\Routing\\Route::run()"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 130,
"call": "Illuminate\\Routing\\Router::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Middleware\\AttemptAuthentication.php",
"line": 34,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AttemptAuthentication::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Middleware\\AcceptJson.php",
"line": 27,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AcceptJson::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 105,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 683,
"call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 658,
"call": "Illuminate\\Routing\\Router::runRouteWithinStack(instance of Illuminate\\Routing\\Route, instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 624,
"call": "Illuminate\\Routing\\Router::runRoute(instance of Illuminate\\Http\\Request, instance of Illuminate\\Routing\\Route)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 613,
"call": "Illuminate\\Routing\\Router::dispatchToRoute(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 170,
"call": "Illuminate\\Routing\\Router::dispatch(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 130,
"call": "Illuminate\\Foundation\\Http\\Kernel::Illuminate\\Foundation\\Http\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\barryvdh\\laravel-debugbar\\src\\Middleware\\InjectDebugbar.php",
"line": 67,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Barryvdh\\Debugbar\\Middleware\\InjectDebugbar::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\app\\Http\\Middleware\\ChangeAppUrlMiddleware.php",
"line": 23,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "App\\Http\\Middleware\\ChangeAppUrlMiddleware::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php",
"line": 27,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php",
"line": 63,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\fideloper\\proxy\\src\\TrustProxies.php",
"line": 57,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Fideloper\\Proxy\\TrustProxies::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php",
"line": 111,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 171,
"call": "Dingo\\Api\\Http\\Middleware\\Request::handle(instance of Illuminate\\Http\\Request, instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 105,
"call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 145,
"call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)"
},
{
"file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 110,
"call": "Illuminate\\Foundation\\Http\\Kernel::sendRequestThroughRouter(instance of Illuminate\\Http\\Request)"
},
{
"file": "E:\\wwwroot\\object\\public\\index.php",
"line": 57,
"call": "Illuminate\\Foundation\\Http\\Kernel::handle(instance of Illuminate\\Http\\Request)"
}
]
}
],
"data": {
"onlineStoreThemeAssetCreate": {
"themeAsset": null
}
}
}
15. Structure when the request response is successful. as shown in Figure 15
mutation {
onlineStoreThemeAssetCreate(
input: { themeId: "vogue", content: "string", key: "string" }
) {
themeAsset {
id
themeId
content
key
mimeType
category
schema
createdAt
updatedAt
deletable
renameable
updatable
}
}
}
{
"data": {
"onlineStoreThemeAssetCreate": {
"themeAsset": {
"id": "653",
"themeId": "vogue",
"content": "string",
"key": "string",
"mimeType": "text/x-php",
"category": "unknown",
"schema": null,
"createdAt": "2022-02-25 01:49:53",
"updatedAt": "2022-02-25 01:49:53",
"deletable": false,
"renameable": false,
"updatable": false
}
}
}
}


![在 GraphQL 中未实现创建模板文件的 API。决定参考 productCreate ( input ProductInput!, media [CreateMediaInput!] ) ProductCreatePayload Creates a product.。](https://www.shuijingwanwq.com/wp-content/uploads/2022/03/3-15.png)











