从 REST 迁移到 GraphQL 的一些思考与实践(创建资源),参考 Shopify
1、新增 template ,创建模板。如图1
2、点击保存按钮,查看网络请求。请求网址: https://xxx.myshopify.com/admin/themes/111/assets 。请求方法: POST。这是 REST 实现。如图2
请求的表单数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 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" ] } |
响应数据:
1 2 3 4 5 6 7 8 9 10 11 12 | { "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、在 GraphQL 中未实现创建模板文件的 API。决定参考 productCreate ( input ProductInput!, media [CreateMediaInput!] ) ProductCreatePayload Creates a product.。如图3
4、测试请求与响应结构,先测试响应失败的结构。如图4
请求数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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 } } |
响应数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 | { "errors": [ { "message": "Parse error on \"{\" (LCURLY) at [3, 29]", "locations": [ { "line": 3, "column": 29 } ] } ] } |
5、测试请求与响应结构,测试响应成功的结构。但是响应失败。如图5
请求数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | mutation { productCreate( input: { title: "标题 20220223 2", } ) { product { ... product ... userErrors } } fragment product on ProductCreatePayload { product { title } } fragment userErrors on ProductCreatePayload { userErrors { field message } } |
响应数据:
1 2 3 4 5 6 7 8 | { "errors": [ { "message": "Unexpected end of document", "locations": [] } ] } |
6、决定在 Shopify 后台 手动添加一件产品,查看网络请求,其是请求的 GraphQL API,参考其请求参数,复制至 Altair 的请求中。点击选择 query,然后右键复制值。如图6
7、粘贴至 Altair 的查询中。如图7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 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、点击选择 variables,然后右键复制值。如图8
9、粘贴至 Altair 的变量中。如图9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | { "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、发送请求报错,响应:Field ‘resourceAlerts’ doesn’t exist on type ‘Product’。在查询中依次删除:resourceAlerts、showUnitPrice、unitPriceMeasurement、standardProductType。如图10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | { "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、发送请求报错,响应: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)。在变量中依次删除:standardProductType、variants.0.inventoryItem.countryCodeOfOrigin、variants.0.inventoryItem.provinceCodeOfOrigin、variants.0.inventoryItem.harmonizedSystemCode、variants.0.showUnitPrice、variants.0.unitPriceMeasurement、workflow。如图11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | { "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、创建产品成功。响应 200。如图12
请求查询:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | 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 } |
请求变量:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | { "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": [] } } |
响应:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | { "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、为何 Shopify 后台调用 GraphQL API 的请求参数与最新版本的 GraphQL API 不相匹配,初步怀疑可能是版本不一致所导致。Shopify 后台调用 GraphQL API 的版本不是最新版本。现在最新版本为:2022-01。而后台调用的版本为:2020-07。如图13
14、当请求响应报错时的结构。如图14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | mutation { onlineStoreThemeAssetCreate( input: { themeId: "vogue", content: "string", key: "string" } ) { themeAsset { id themeId version content key mimeType category schema createdAt updatedAt deletable renameable updatable } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | { "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、当请求响应成功时的结构。如图15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | mutation { onlineStoreThemeAssetCreate( input: { themeId: "vogue", content: "string", key: "string" } ) { themeAsset { id themeId content key mimeType category schema createdAt updatedAt deletable renameable updatable } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | { "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 } } } } |
近期评论