Company
Date Published
Dec. 10, 2024
Author
Jerel Miller
Word count
909
Language
English
Hacker News points
None

Summary

The Apollo Client 3.12 release focuses on improving code resilience with data masking. Data masking allows components to only receive the fields requested by a query or fragment, reducing implicit dependencies between components and making the application more maintainable. This is achieved through the use of colocated fragments where components define their data requirements using GraphQL fragments. The `useFragment` hook is used to read fragment data from a query, optimizing renders in the React app and making it more predictable and performant. Data masking can be enabled by setting the `dataMasking` option to true in the Apollo Client instance, and can be incrementally adopted through the use of client-only directives like `@unmask`, which allow developers to determine what would break if a fragment were masked. The release also includes TypeScript integration with GraphQL Codegen's Fragment Masking feature.