Shopify / js-buy-sdk

The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.

Home Page:https://shopify.github.io/js-buy-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No field of name "pageInfo" found on type "Metafield" in schema. No field of name "tags" found on type "Product" in schema

JeffJassky opened this issue · comments

Bug details

Describe the bug

While using the Shopify GraphQL API through the SDK, a new error is consistently surfacing that wasn't previously an issue. The error indicates a problem with the field 'pageInfo' on the type 'Metafield'. At the same time this error happened, the bug reported in #959 and #949 also happened. This application was working as expected until recently without any changes on our end. It appears a change or update on Shopify's end may have caused this new issue.

To Reproduce

The error arises every time we attempt a query involving the 'pageInfo' field on the type 'Metafield' or tags on Product type. The exact error message is:
No field of name "pageInfo" found on type "Metafield" in schema. and
No field of name "tags" found on type "Product" in schema

Unfortunately, I cannot provide the X-Request-ID as the errors are being handled within the SDK.

Expected behavior

Queries involving the 'pageInfo' field on 'Metafield' should function as they have in the past, without returning any errors. If changes have been made to the Shopify GraphQL API that affects these queries, they should be documented in the SDK's release notes or changelog.

Environment (please complete the following information):

  • OS: macOS, Ubuntu
  • Browser: Chrome, Firefox, IE, Edge
  • SDK Version: v2.20.0, v2.0.1 and others

The problem:

All API versions before 2022-10 have been fully discontinued this week. Requests made to earlier versions are now processed by the oldest version that is currently supported, which is 2022-10. This means anything deprecated before 2022-10 has stopped working completelly.

The fix:

  1. Upgrade to the latest version of the library for best practices (2.20.0 as of this post).
  2. Update your GraphQL queries to remove references to deprecated data structures and replace them the newly available data structures.

To migrate metadata fields (for products, collections, etc), I have made these changes:

object.addConnection('metafields', {args: {first: 5}}, (metafield) => {
    metafield.add('namespace')
    metafield.add('key')
    metafield.add('value')
});

to:

  object.add('metafields', {
    args: {
      identifiers: [
        {
          key: "color",
          namespace: "extras"
        },
        {
          key: "size_chart",
          namespace: "extras"
        },
        {
          key: "temporary_collection",
          namespace: "my_fields"
        }
      ]
    }
  }, (metafield) => {
    metafield.add('key');
    metafield.add('namespace');
    metafield.add('value');
  });

and to migrate variant price and compareAtPrice I changed:

variant.add("price");
variant.add("compareAtPrice");

To:

variant.add('priceV2', (price) => {
    price.add('amount');
    price.add('currencyCode');
});
variant.add('compareAtPriceV2', (comparePrice) => {
    comparePrice.add('amount');
    comparePrice.add('currencyCode');
});

Unfortunately, ProductVariant.presentmentFields has been discontinued entirely and we are now supposed to use a different approach called @incontext, which is not yet supported by this library.

Marking closed.