Apollo Client (Web)
IntroductionWhy Apollo Client?Get started
Core concepts
Caching
Pagination
Local State
Development & Testing
Performance
Integrations
Networking
API Reference
ChangelogMigrating to Apollo Client 4.0Versioning Policy

LocalStateError

API reference


Represents a fatal error when executing @client fields from LocalState, typically to indicate a problem with the LocalState configuration or incorrect usage of a resolver function. This error does not represent user errors thrown in a local resolver when resolving @client fields.

TypeScript
1 import { LocalStateError } from "@apollo/client/errors";
2
3 // Check if an error is a LocalStateError instance
4 if (LocalStateError.is(error)) {
5   console.log("Original error:", error.cause);
6
7   // Determine which field caused the error
8   if (error.path) {
9     console.log("Error occurred at field path:", error.path.join("."));
10   }
11 }

Static methods

A method that determines whether an error is a LocalStateError object. This method enables TypeScript to narrow the error type.

Example

TypeScript
1 if (LocalStateError.is(error)) {
2   // TypeScript now knows `error` is a LocalStateError object
3   console.log(error.path);
4 }

Signature

TypeScript
1is(
2  error: unknown
3): error is LocalStateError

See the instance properties for more details about the available properties provided by the LocalStateError object.

Instance properties

These properties are specific to the LocalStateError object. Standard error instance properties are also available.

tip
The cause property contains the original error thrown by local resolvers when exporting variables for @export directive fields.
Array<string | number>

The path to the field that caused the error.