diff --git a/packages/store/src/-private/cache-handler/handler.ts b/packages/store/src/-private/cache-handler/handler.ts index 1170a673cc9..fe5ac0c14e2 100644 --- a/packages/store/src/-private/cache-handler/handler.ts +++ b/packages/store/src/-private/cache-handler/handler.ts @@ -19,7 +19,6 @@ import type { import type { ApiError } from '@warp-drive/core-types/spec/error'; import type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/json-api-raw'; -import type { OpaqueRecordInstance } from '../../-types/q/record-instance'; import { Document } from '../document'; import type { Store } from '../store-service'; import { @@ -246,11 +245,11 @@ function maybeUpdateErrorUiObjects( ): ResourceErrorDocument { const { identifier } = options; - assert(`Expected an error document`, isErrorDocument(document)); - - if (!identifier && !options.shouldHydrate) { + // TODO investigate why ResourceErrorDocument is insufficient for expressing all error types + if (!isErrorDocument(document) || (!identifier && !options.shouldHydrate)) { return document; } + let doc: Document | undefined; if (identifier) { doc = store._documentCache.get(identifier) as Document | undefined; diff --git a/packages/store/src/-private/cache-handler/utils.ts b/packages/store/src/-private/cache-handler/utils.ts index f12fafafe3b..f5587783909 100644 --- a/packages/store/src/-private/cache-handler/utils.ts +++ b/packages/store/src/-private/cache-handler/utils.ts @@ -1,3 +1,4 @@ +import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier'; import type { ImmutableCreateRequestOptions, ImmutableDeleteRequestOptions, @@ -5,10 +6,10 @@ import type { ImmutableUpdateRequestOptions, StructuredDataDocument, } from '@warp-drive/core-types/request'; -import type { Store } from '../store-service'; -import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier'; -import type { ApiError } from '@warp-drive/core-types/spec/error'; import type { ResourceDataDocument, ResourceErrorDocument } from '@warp-drive/core-types/spec/document'; +import type { ApiError } from '@warp-drive/core-types/spec/error'; + +import type { Store } from '../store-service'; export const MUTATION_OPS = new Set(['createRecord', 'updateRecord', 'deleteRecord']); diff --git a/packages/store/src/-private/store-service.ts b/packages/store/src/-private/store-service.ts index 4d1a1031c32..05fdba7fd97 100644 --- a/packages/store/src/-private/store-service.ts +++ b/packages/store/src/-private/store-service.ts @@ -40,6 +40,7 @@ import type { OpaqueRecordInstance } from '../-types/q/record-instance'; import type { SchemaService } from '../-types/q/schema-service'; import type { FindAllOptions, FindRecordOptions, LegacyResourceQuery, QueryOptions } from '../-types/q/store'; import type { StoreRequestInput } from './cache-handler/handler'; +import type { CachePolicy } from './cache-handler/types'; import { IdentifierCache } from './caches/identifier-cache'; import { InstanceCache, @@ -60,7 +61,6 @@ import type { Collection, IdentifierArray } from './record-arrays/identifier-arr import { coerceId, ensureStringId } from './utils/coerce-id'; import { constructResource } from './utils/construct-resource'; import { normalizeModelName } from './utils/normalize-model-name'; -import type { CachePolicy } from './cache-handler/types'; export { storeFor };