Skip to content

graphql query method throws FeatureDeprecatedError exception #2928

@Kevin-Hamilton

Description

@Kevin-Hamilton

Issue summary

Before opening this issue, I have:

  • Upgraded to the latest version of the relevant packages
    • @shopify/* package and version: 12.1.1
    • Node version: 24.7.0
    • Operating system: MacOS 14.7.7
  • Set { logger: { level: LogSeverity.Debug } } in my configuration, when applicable
  • Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • Looked for similar issues in this repository
  • Checked that this isn't an issue with a Shopify API

Expected behavior

Deprecation of graphql client.query should be extended OR error message should be more helpful AND documentation should be updated.

Actual behavior

Exception is thrown, stating

FeatureDeprecatedError: Feature was deprecated in version 12.0.0
    at Object.deprecated (file:///Users/kevinhamilton/Sites/htdocs/qt/shopify-api/node_modules/@shopify/shopify-api/dist/esm/lib/logger/index.mjs:21:19)
    at NewGraphqlClient.query (file:///Users/kevinhamilton/Sites/htdocs/qt/shopify-api/node_modules/@shopify/shopify-api/dist/esm/lib/clients/admin/graphql/client.mjs:37:44)
...

Steps to reproduce the problem

  1. npm install @shopify/shopify-api
  2. Create the following example test.js script:
import '@shopify/shopify-api/adapters/node';
import {shopifyApi, ApiVersion} from '@shopify/shopify-api';

const SHOP_ID = 'SITENAME.myshopify.com';
const CLIENT_ID = 'your-client-id';
const API_SECRET = 'your-api-secret';

const shopify = shopifyApi({
  apiKey: CLIENT_ID,
  apiSecretKey: API_SECRET,
  scopes: ['read_online_store_pages', 'write_online_store_pages', 'read_content', 'write_content'],
  hostName: 'http://localhost:3000',
  apiVersion: ApiVersion.October25
});


async function authenticate() {
  const shop = shopify.utils.sanitizeShop(SHOP_ID, true);
  const response = await shopify.auth.clientCredentials({
    shop
  });
  return response.session;
}

try {
  const session = await authenticate();
  const client = new shopify.clients.Graphql({session});
  const data = await client.query({
    data: `query BlogList {
      blogs(first: 50) {
        nodes {
          id
          handle
          title
          updatedAt
          commentPolicy
          createdAt
        }
      }
    }`,
  });
  console.log(data);
} catch (error) {
  console.log('Error making API request: ' + error.message);
}
  1. node test.js

Discussion

I'm creating a one-off script to import blog articles into a shopify site.

I started by setting up the client credentials grant as explained here and here

I then tried to interact with the GraphQL Admin Api as documented on the Node.JS tab here but I was presented with the very unhelpful error condition of "Feature was deprecated in version 12.0.0".

Throughout the GraphQL Admin API documentation, the Node.JS examples all use the GraphQL client.query method.

Digging into this, I found that in versions prior to 12.0.0, the query method would apparently work but would log a warning about how the query method was deprecated and to use the request method instead:

'The query method is deprecated, and was replaced with the request method.\n' +
'See the migration guide: https://github.com/Shopify/shopify-app-js/blob/main/packages/apps/shopify-api/docs/migrating-to-v9.md#using-the-new-clients.',

however now that we are past version 12, there is no warning or helpful message, just an opaque exception thrown:
if (compare(SHOPIFY_API_LIBRARY_VERSION, version, '>=')) {
throw new FeatureDeprecatedError(
`Feature was deprecated in version ${version}`,
);

The message, "Feature was deprecated in version 12.0.0" isn't even really accurate. The feature was actually deprecated in v9 and removed in v12... But it wasn't actually removed from v12 either, the backward compatibility code remains in the package, but is just unreachable due to the exception.

I was surprised when I first ran into this error that there was no mention in the v12 changelog or migration guides about this. Digging around, I eventually found it documented in the "migrating to v9" guide: https://github.com/Shopify/shopify-app-js/blob/main/packages/apps/shopify-api/docs/migrating-to-v9.md#using-the-new-clients I also found that this deprecation had been previously postponed from v10 to v11: #825 and from v11 to v12: 433903b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions