Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): add default values to releases metadata #8484

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions packages/sanity/src/core/releases/store/createReleaseStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {listenQuery} from '../../store/_legacy'
import {RELEASE_DOCUMENT_TYPE, RELEASE_DOCUMENTS_PATH} from './constants'
import {createReleaseMetadataAggregator} from './createReleaseMetadataAggregator'
import {releasesReducer, type ReleasesReducerAction, type ReleasesReducerState} from './reducer'
import {type ReleaseDocument, type ReleaseStore} from './types'
import {type ReleaseDocument, type ReleaseStore, type ReleaseType} from './types'

type ActionWrapper = {action: ReleasesReducerAction}
type ResponseWrapper = {response: ReleaseDocument[]}
Expand All @@ -31,6 +31,7 @@ export const SORT_ORDER = 'desc'

const QUERY_FILTER = `_type=="${RELEASE_DOCUMENT_TYPE}" && _id in path("${RELEASE_DOCUMENTS_PATH}.*")`

const DEFAULT_RELEASE_TYPE: ReleaseType = 'undecided'
const QUERY_PROJECTION = `{
_id,
_type,
Expand All @@ -40,12 +41,10 @@ const QUERY_PROJECTION = `{
state,
finalDocumentStates,
publishAt,
metadata {
title,
description,
intendedPublishAt,
releaseType
}
"metadata": coalesce(metadata, {
"title": "",
"releaseType": "${DEFAULT_RELEASE_TYPE}",
}),
}`

// Newest releases first
Expand Down
Loading