Change8

@apollo/client@4.3.0-rc.1

Breaking Changes
📦 apollo-clientView on GitHub →
2 breaking1 features🐛 1 fixes🔧 6 symbols

Summary

Introduced support for scalars that are arrays, allowing for more precise type handling in field policies and input objects. Also fixed an issue with the `variables` property in mutation update functions.

⚠️ Breaking Changes

  • The field policy `scalar` option and `inputObjects` type string now use GraphQL list syntax to mark a field as a list of scalars. Previously, all arrays were iterated and only the inner type was provided to the scalar `parse`/`serialize` functions.
  • The abstract `cache.getScalarForField` is now `cache.getScalarTypeForField` and is expected to return the string representing the scalar type rather than the `Scalar` instance.

Migration Steps

  1. Update field policy `scalar` options and `inputObjects` type strings to use GraphQL list syntax (e.g., `[TypeName]` for lists, `[[TypeName]]` for lists of lists) when defining fields that are arrays of scalars.
  2. Replace calls to `cache.getScalarForField` with `cache.getScalarTypeForField` and ensure it returns the scalar type string.

✨ New Features

  • Field policies and `inputObjects` can now specify if a field is a list of scalars or a scalar whose value is an array, allowing for better handling of scalars represented by arrays.

🐛 Bug Fixes

  • The optional modifier has been removed from the `variables` property provided to the `update` function in `client.mutate` and `useMutation`. The `variables` property is now always a defined object, even when no variables are provided to the mutation.

Affected Symbols