I’m using the buy-sdk in a browser, with the javascript from the CDN.
This worked perfectly last night. I come in today and it’s broken.
The error is: 'Field ‘collections’ doesn’t exist on type ‘Shop’
The same problem happens when requesting Products
When I run this standard simple code:
client = ShopifyBuy.buildClient({
domain: ‘my-first-dev-store123.myshopify.com’,
storefrontAccessToken: ‘< my access token here>’
});
var collections = await client.collection.fetchAll();
the fiddler SEND looks like this:
POST https://my-first-dev-store123.myshopify.com/api/graphql HTTP/1.1
Host: my-first-dev-store123.myshopify.com
Connection: keep-alive
Content-Length: 439
sec-ch-ua: “Not_A Brand”;v=“99”, “Google Chrome”;v=“109”, “Chromium”;v=“109”
X-SDK-Version: 1.11.0
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
X-SDK-Variant: javascript
Content-Type: application/json
Accept: application/json
X-Shopify-Storefront-Access-Token: < this is my access token here>
sec-ch-ua-platform: “Windows”
Origin: http://localhost:5500
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:5500/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
{“query”:“fragment CollectionFragment on Collection { id,handle,description,descriptionHtml,updatedAt,title,image { id,src: originalSrc,altText } },query ($first:Int!,$query:String,$sortKey:CollectionSortKeys,$reverse:Boolean) { shop { collections (first: $first query: $query sortKey: $sortKey reverse: $reverse) { pageInfo { hasNextPage,hasPreviousPage },edges { cursor,node { …CollectionFragment } } } } }”,“variables”:{“first”:20}}
and the RESPONSE:
HTTP/1.1 200 OK
Date: Sun, 15 Jan 2023 18:40:54 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
X-Sorting-Hat-PodId: 286
X-Sorting-Hat-ShopId: 67118006559
X-Storefront-Renderer-Rendered: 1
Vary: Accept-Encoding
Vary: Accept
X-Frame-Options: DENY
Content-Security-Policy: block-all-mixed-content; frame-ancestors ‘none’; upgrade-insecure-requests;
Access-Control-Allow-Origin: *
X-Shopify-API-Version: 2022-04
X-ShopId: 67118006559
X-ShardId: 286
Content-Language: en-US
Server-Timing: processing;dur=28, db;dur=11, asn;desc=“22995”, edge;desc=“SEA”, country;desc=“CA”
X-Shopify-Stage: production
X-Dc: gcp-us-west1,us-central1,gcp-us-central1
X-Request-ID: cd1437b8-9bae-4d48-b652-dcb01258337b
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
CF-Cache-Status: DYNAMIC
Report-To: {“endpoints”:[{“url”:“https://a.nel.cloudflare.com/report/v3?s=Q45XZGSbFda4tUQ65jQjp%2B24t3Op3U48Mxw0Pny95fov9W32pHZWul8v6h%2F%2FvX2U7EGpECg60sQPNtD1YLL0uof8Xhtec4xWTOSQNu%2BDRPyM7anB2uLRd%2BhowkFdT3kU1od7RqLutrVrCGcmUBWyGwpmPbxA”}],“group”:“cf-nel”,“max_age”:604800}
NEL: {“success_fraction”:0.01,“report_to”:“cf-nel”,“max_age”:604800}
Server-Timing: cfRequestDuration;dur=85.999966
Server: cloudflare
CF-RAY: 78a0be11f819283e-SEA
alt-svc: h3=“:443”; ma=86400, h3-29=“:443”; ma=86400
Content-Length: 1234
{“errors”:[{“message”:“Field ‘collections’ doesn’t exist on type ‘Shop’”,“locations”:[{“line”:1,“column”:229}],“path”:[“query”,“shop”,“collections”],“extensions”:{“code”:“undefinedField”,“typeName”:“Shop”,“fieldName”:“collections”}},{“message”:“Variable $first is declared by anonymous query but not used”,“locations”:[{“line”:1,“column”:140}],“path”:[“query”],“extensions”:{“code”:“variableNotUsed”,“variableName”:“first”}},{“message”:“Variable $query is declared by anonymous query but not used”,“locations”:[{“line”:1,“column”:140}],“path”:[“query”],“extensions”:{“code”:“variableNotUsed”,“variableName”:“query”}},{“message”:“Variable $sortKey is declared by anonymous query but not used”,“locations”:[{“line”:1,“column”:140}],“path”:[“query”],“extensions”:{“code”:“variableNotUsed”,“variableName”:“sortKey”}},{“message”:“Variable $reverse is declared by anonymous query but not used”,“locations”:[{“line”:1,“column”:140}],“path”:[“query”],“extensions”:{“code”:“variableNotUsed”,“variableName”:“reverse”}},{“message”:“Fragment CollectionFragment was defined, but not used”,“locations”:[{“line”:1,“column”:1}],“path”:[“fragment CollectionFragment”],“extensions”:{“code”:“useAndDefineFragment”,“fragmentName”:“CollectionFragment”}}]}