faustjs icon indicating copy to clipboard operation
faustjs copied to clipboard

Deprecation Warnings: Apollo Client `canonizeResults` and `cache.diff` Options

Open bpkennedy opened this issue 2 months ago • 2 comments

Description

Problem Description

During Next.js build process (next build), we're seeing deprecation warnings from Apollo Client 3.14.0 related to deprecated options canonizeResults and cache.diff. These warnings are being generated by Faust.js's internal Apollo Client usage during getWordPressProps calls.

Error Messages

The following warnings appear multiple times during the build output:

An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#%7B%22version%22%3A%223.14.0%22%2C%22message%22%3A104%2C%22args%22%3A%5B%22cache.diff%22%2C%22canonizeResults%22%2C%22Please%20remove%20this%20option.%22%5D%7D

Decoded error details:

  • Error Code: 104
  • Deprecated Options: cache.diff, canonizeResults
  • Message: "Please remove this option."

Environment

Frontend (Next.js)

Backend (WordPress)

  • WordPress Version: 6.6.1
  • FaustWP Plugin Version: 1.8.0

Root Cause

The warnings originate from Faust.js's internal Apollo Client instances created during:

  • getWordPressProps() calls in getStaticProps
  • Server-side rendering operations

These internal Apollo Client instances appear to be using deprecated options (canonizeResults and cache.diff) that were:

  • Deprecated in Apollo Client 3.11
  • Removed in Apollo Client 3.14

Impact

  • Build Status: ✅ Builds complete successfully (warnings only, not errors)
  • Functionality: ✅ No functional impact observed
  • Developer Experience: ⚠️ Build output is cluttered with repeated warnings

Steps to Reproduce

  1. Setup a Next.js project with Faust.js:

    # Install dependencies
    yarn add @faustwp/core@^3.0.1 @apollo/client@^3.10.5 next@^15.0.0
    
    # Add yarn resolution to ensure Apollo Client 3.14.0
    # In package.json:
    "resolutions": {
      "@apollo/client": "3.14.0"
    }
    
    yarn install
    
  2. Create a page using getWordPressProps:

    // pages/[...wordpressNode].tsx
    import { getWordPressProps, WordPressTemplate } from '@faustwp/core'
    import { GetStaticProps } from 'next'
    
    export default function Page(props) {
      return <WordPressTemplate {...props} />
    }
    
    export const getStaticProps: GetStaticProps = (ctx) => {
      return getWordPressProps({
        ctx,
        revalidate: 600,
      })
    }
    
  3. Run the build:

    yarn build
    
  4. Observe warnings in build output - The warnings will appear multiple times during static page generation, once for each page that uses getWordPressProps().

Note: The warnings only appear during build (next build), not during development (next dev). This is because getStaticProps runs during the build process.

Expected Behavior

  • No deprecation warnings during build
  • Faust.js's internal Apollo Client instances should use Apollo Client 3.14+ compatible options

Suggested Solution

Update Faust.js's internal Apollo Client configuration to:

  1. Remove any usage of canonizeResults option in InMemoryCache configuration
  2. Remove any usage of cache.diff method
  3. Ensure all InMemoryCache instances are created without deprecated options

Additional Context

We've already:

  • ✅ Updated our own Apollo Client instances to explicitly configure InMemoryCache without deprecated options
  • ✅ Added yarn resolution to ensure consistent Apollo Client version (@apollo/[email protected])
  • ✅ Verified warnings are coming from Faust.js's internal usage, not our code
  • ✅ Confirmed the warnings appear regardless of our own Apollo Client configuration

Verification:

  • We searched our codebase and confirmed we're not using canonizeResults or cache.diff anywhere
  • The warnings persist even after updating all our InMemoryCache instances to explicitly avoid deprecated options
  • The warnings only appear during build when getWordPressProps() is called, not during development

The warnings are non-blocking but should be addressed to maintain compatibility with Apollo Client 3.14+ and future versions.

Related Issues


Note: This is a good citizen issue report. We're happy to help test any fixes or provide additional information if needed.

Steps to reproduce

above

Additional context

above

@faustwp/core Version

3.3.2

@faustwp/cli Version

3.3.1

FaustWP Plugin Version

1.8.0

WordPress Version

6.6.1

Additional environment details

No response

Please confirm that you have searched existing issues in the repo.

  • [x] Yes

bpkennedy avatar Nov 05 '25 16:11 bpkennedy

Thanks @bpkennedy for reporting this issue.

We couldn't reproduce this issue locally with the instructions you've provided. Also we couldn't find any reference to canonizeResults or cache.diff in our codebase (1, 2).

Could you please double check your dependencies for possible conflict?

ahuseyn avatar Nov 06 '25 11:11 ahuseyn

@ahuseyn Thank you for investigating! You were absolutely right - this is NOT a Faust.js issue.

Root Cause: Apollo Client 3.14.0 has a bug where it internally uses deprecated methods (cache.diff) and tries to suppress its own warnings, but the suppression fails during Next.js builds and runtime. This creates severe log pollution (166+ warnings in my build).

Evidence from Apollo Client 3.14.0 source code:

// node_modules/@apollo/client/core/QueryInfo.js
var diff = muteDeprecations("canonizeResults", function () {
    return _this.cache.diff(options);
});

Apollo Client calls cache.diff() internally on every query and attempts to mute its own deprecation warnings, but the muteDeprecations() mechanism is failing in Next.js build/runtime contexts.

Solution: Downgrade to Apollo Client 3.13.9:

{
  "dependencies": {
    "@apollo/client": "3.13.9"
  }
}

Results: Zero warnings, clean logs ✅

This affects any project using Apollo Client 3.14.0, not just Faust.js. You may want to add a documentation note warning users about this version until Apollo fixes the bug.

Thanks again for your help!

bpkennedy avatar Nov 06 '25 16:11 bpkennedy