Skip to content

Version Packages (alpha)#13297

Merged
jerelmiller merged 2 commits into
release-4.3from
changeset-release/release-4.3
Jun 30, 2026
Merged

Version Packages (alpha)#13297
jerelmiller merged 2 commits into
release-4.3from
changeset-release/release-4.3

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to release-4.3, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

release-4.3 is currently in pre mode so this branch has prereleases rather than normal releases. If you want to exit prereleases, run changeset pre exit on release-4.3.

⚠️⚠️⚠️⚠️⚠️⚠️

Releases

@apollo/client@4.3.0-alpha.2

Minor Changes

  • #13274 7b10078 Thanks @jerelmiller! - Adds Scalar.fromGraphQLScalarType helper to create a Scalar instance from an existing graphql.js GraphQLScalarType.

    import { GraphQLScalarType } from "graphql";
    import { Scalar } from "@apollo/client";
    
    const dateTimeScalarType = new GraphQLScalarType<Date, string>({
      // ...
    });
    
    const dateTimeScalar = Scalar.fromGraphQLScalarType(dateTimeScalarType, {
      is: (value) => value instanceof Date,
    });
  • #13252 ed86234 Thanks @jerelmiller! - Adds the plumbing and types implementation for declaring custom scalars and configuring custom scalars in InMemoryCache.

    You can declare custom scalar types with declaration merging on the ApolloCache.Scalars interface:

    // apollo.d.ts
    import "@apollo/client";
    
    declare module "@apollo/client" {
      namespace ApolloCache {
        interface Scalars {
          Date: { serialized: string; parsed: Date };
        }
      }
    }

    This enables the scalars option in InMemoryCache:

    import { Scalar } from "@apollo/client";
    
    const cache = new InMemoryCache({
      scalars: {
        Date: new Scalar({
          parse: (dateString) => new Date(dateString),
          serialize: (date) => date.toISOString(),
          is: (value) => value instanceof Date,
        }),
      },
    });
  • #13259 ccaf686 Thanks @jerelmiller! - Adds a scalar option to InMemoryCache field policies that tells the cache which scalar to use when parsing or serializing the field value.

    import { Scalar } from "@apollo/client";
    
    new InMemoryCache({
      scalars: {
        DateTime: new Scalar({
          parse: (dateString) => new Date(dateString),
          serialize: (date) => date.toISOString(),
        }),
      },
      typePolicies: {
        Event: {
          fields: {
            startTime: {
              // Parse this field using the DateTime scalar
              scalar: "DateTime",
            },
          },
        },
      },
    });

    This scalar definition is now used to properly parse or serialize the field value for cache reads and writes as well as cache.extract() and cache.restore().

  • #13273 0886de1 Thanks @jerelmiller! - Automatically serialize variables that include custom scalar values. This includes cache reads and writes as well as requests to the network.

    For more complex input objects, a new inputObjects option is available to InMemoryCache that specifies where nested scalar fields are found.

    const cache = new InMemoryCache({
      scalars: {
        DateTime: new Scalar({
          parse: (value) => new Date(value),
          serialize: (value) => value.toISOString(),
          is: (value) => value instanceof Date,
        }),
      },
      inputObjects: {
        EventFilter: {
          fields: {
            date: "DateTime",
          },
        },
      },
    });
    
    const client = new ApolloClient({ cache, link });
    
    await client.query({
      query: gql`
        query Event($filter: EventFilter!) {
          event(filter: $filter) {
            name
          }
        }
      `,
      variables: {
        filter: {
          date: new Date("2026-01-01T00:00:00.000Z"),
        },
      },
    });
    
    // The link receives:
    // { filter: { date: "2026-01-01T00:00:00.000Z" } }
  • #13252 ed86234 Thanks @jerelmiller! - Adds the getScalar abstract method to ApolloCache that cache subclasses override to provide scalar behavior to Apollo Client. Defaults to unconditionally return undefined if not specified.

@apollo-librarian

apollo-librarian Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 7f3871a2cc2ff17123f8b162
Build Logs: View logs


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@github-actions github-actions Bot force-pushed the changeset-release/release-4.3 branch from ebc9448 to 171bf61 Compare June 30, 2026 18:08
@github-actions github-actions Bot force-pushed the changeset-release/release-4.3 branch from 171bf61 to 7cc9af9 Compare June 30, 2026 18:22
@jerelmiller jerelmiller enabled auto-merge (squash) June 30, 2026 18:34
@pkg-pr-new

pkg-pr-new Bot commented Jun 30, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@apollo/client@13297

commit: f179ba4

@jerelmiller jerelmiller merged commit aba0960 into release-4.3 Jun 30, 2026
46 checks passed
@jerelmiller jerelmiller deleted the changeset-release/release-4.3 branch June 30, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant