MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
945 stars 278 forks source link

Metafield.valueType has been removed(deprecated calls) #551

Closed sekretov closed 1 year ago

sekretov commented 1 year ago

Metafield.valueType or value_type has been removed, please replace all REST "value_type" or graphql valueType with "type" 1 oct shopify deadline.

Shubham-Sapient commented 1 year ago

@lpinca , @sekretov any estimate when this will be pushed?

Shubham-Sapient commented 1 year ago

hi @lpinca @sekretov , received below email from shopify , could you please assist me to understand the impact and when shall this be fixed.

mail from Shopify--->

Breaking changes:

The origin_location and destination_location fields on line items have been deprecated from Admin REST API's Order resource. View change.

As of 2022-10, the Money scalar is being removed from the Storefront API, and fields with V2 ({field}V2: MoneyV2) suffixes are being deprecated. Please check the changelog notes for full details of the change. View change.

The total_price_usd field on Order has been deprecated from the Admin REST API's Order resource. View change. Metafield.valueType has been removed. See Metafield.type for type information. View change.

Multi Managed Inventory introduced a breaking change to the Order.line_items.fulfillment_service field. This field is due to be deprecated from both the Admin GraphQL and the Admin REST APIs. When using the GraphQL API, consider using FulfillmentOrder.assigned_location. When using the REST API, see FulfillmentOrder.assigned_location. View change.

Some customer fields have been deprecated from the Admin REST API's Order resource. View change.

lpinca commented 1 year ago

@Shubham-Sapient you have to do nothing and nothing needs to change in shopify-api-node. Just stop using those fields.

Shubham-Sapient commented 1 year ago

thanks for the suggestion @lpinca, we are not using any of those fields in the codebase still received the notification. so I thought maybe it was because of the library. could you please confirm that it will not break anything existing?

lpinca commented 1 year ago

None of those fields exist in the library. They might exists in the TypeScript type definitions but they have no effect on what is sent or received.

Shubham-Sapient commented 1 year ago

alright thanks for the help! have a great day...

CoolTechYT commented 1 year ago

We're not using metafield.valueType at all in our usage of this repo, but when querying the metafields we created with this app, they all have the metafield.valueType property.

I'm assuming it's because the version I'm using is 3.9.0, and not specifying API_VERSION so the default is probably prior to the depreciation of metafield.valueType.

Will specify the API_VERSION on the newer API calls and report if that fixes the problem.

CoolTechYT commented 1 year ago

Just updated apiVersion to 2022-10, and this is the result...


const shopify = new Shopify({ accessToken, shopName: shop, apiVersion: "2022-10" });
const metafield = await shopify.metafield.create({
  namespace: "test",
  key: "test",
  value: false,
  type: "boolean"
});

  {
    id: xxx,
    namespace: 'test',
    key: 'test',
    value: true,
    value_type: 'boolean',
    description: null,
    owner_id: 69854920981,
    created_at: '2023-01-01T11:41:10-05:00',
    updated_at: '2023-01-01T11:43:04-05:00',
    owner_resource: 'shop',
    type: 'boolean',
    admin_graphql_api_id: 'gid://shopify/Metafield/xxx'
  },

As you can see it is creating the value_type property @lpinca

lpinca commented 1 year ago

I can't reproduce:

$ cat gh-551.mjs 
import assert from 'node:assert';
import Shopify from 'shopify-api-node';

const shopify = new Shopify({
  shopName: 'quuz',
  apiVersion: '2022-10',
  apiKey: 'b68c3a4bf44cd240511e5f4114f0be4d',
  password: '2d170167fc62551920ca60fe40a5e548'
});

const products = await shopify.product.list();

assert.deepStrictEqual(products, []);

const product = await shopify.product.create({
  body_html: '<strong>Good snowboard!</strong>',
  product_type: 'Snowboard',
  title: 'Burton Custom Freestlye 151',
  vendor: 'Burton'
});

const params = {
  metafield: { owner_resource: 'product', owner_id: product.id }
};
let metafields = await shopify.metafield.list(params);

assert.deepStrictEqual(metafields, []);

const metafield = await shopify.metafield.create({
  key: 'warehouse',
  namespace: 'inventory',
  owner_id: product.id,
  owner_resource: 'product',
  value: 25,
  type: 'integer'
});

console.log(metafield);

metafields = await shopify.metafield.list(params);

console.log(metafields);

await Promise.all([
  shopify.product.delete(product.id),
  shopify.metafield.delete(metafield.id)
]);
$ node gh-551.mjs 
{
  id: 20073974464547,
  namespace: 'inventory',
  key: 'warehouse',
  value: 25,
  description: null,
  owner_id: 6762940399651,
  created_at: '2023-01-01T12:50:43-05:00',
  updated_at: '2023-01-01T12:50:43-05:00',
  owner_resource: 'product',
  type: 'integer',
  admin_graphql_api_id: 'gid://shopify/Metafield/20073974464547'
}
[
  {
    id: 20073974464547,
    namespace: 'inventory',
    key: 'warehouse',
    value: 25,
    description: null,
    owner_id: 6762940399651,
    created_at: '2023-01-01T12:50:43-05:00',
    updated_at: '2023-01-01T12:50:43-05:00',
    owner_resource: 'product',
    type: 'integer',
    admin_graphql_api_id: 'gid://shopify/Metafield/20073974464547'
  }
]
CoolTechYT commented 1 year ago

Which package version are you on?

CoolTechYT commented 1 year ago

@lpinca can you try it on the shop resource?

I did just create this metafield however with the above query, and it resulted in the value_type being present, so something is strange.

lpinca commented 1 year ago

3.12.0 but it does not matter. There have been no recent changes regarding metafields.

lpinca commented 1 year ago

@lpinca can you try it on the shop resource?

$ cat gh-551-2.mjs 
import assert from 'node:assert';
import Shopify from 'shopify-api-node';

const shopify = new Shopify({
  shopName: 'quuz',
  apiVersion: '2022-10',
  apiKey: 'b68c3a4bf44cd240511e5f4114f0be4d',
  password: '2d170167fc62551920ca60fe40a5e548'
});

let metafields = await shopify.metafield.list();

assert.deepStrictEqual(metafields, []);

const metafield = await shopify.metafield.create({
  key: 'test',
  namespace: 'test',
  value: false,
  type: 'boolean'
});

console.log(metafield);

metafields = await shopify.metafield.list();

console.log(metafields);

await shopify.metafield.delete(metafield.id);
$ node gh-551-2.mjs 
{
  id: 20073982722083,
  namespace: 'test',
  key: 'test',
  value: false,
  description: null,
  owner_id: 19563841,
  created_at: '2023-01-01T13:13:38-05:00',
  updated_at: '2023-01-01T13:13:38-05:00',
  owner_resource: 'shop',
  type: 'boolean',
  admin_graphql_api_id: 'gid://shopify/Metafield/20073982722083'
}
[
  {
    id: 20073982722083,
    namespace: 'test',
    key: 'test',
    value: false,
    description: null,
    owner_id: 19563841,
    created_at: '2023-01-01T13:13:38-05:00',
    updated_at: '2023-01-01T13:13:38-05:00',
    owner_resource: 'shop',
    type: 'boolean',
    admin_graphql_api_id: 'gid://shopify/Metafield/20073982722083'
  }
]
CoolTechYT commented 1 year ago

@lpinca Figured out why, if you instantiate Shopify without specifying apiVersion it returns value_type in the metafield:

    const shopify = new Shopify({
        shopName: store.myshopify_domain,
        accessToken: store.accessToken
    });

    const shopifyWithVersion = new Shopify({
        shopName: store.myshopify_domain,
        accessToken: store.accessToken,
        apiVersion: "2022-10"
    });

    const metafield = await shopifyWithVersion.metafield.create({
        namespace: "test",
        key: "test",
        value: false,
        type: "boolean",
    });

    console.log(metafield);
    // no value_type property

    const metafields = await shopify.metafield.list({
        namespace: "test",
    });

    console.log(metafields);

    // will show value_type property

I'm trying to figure out why I'm getting this message from Shopify:

Metafield.valueType has been removed. See Metafield.type for type information. View change