How to use the @sanity/base/initial-value-templates.resolveInitialValue function in @sanity/base

To help you get started, we’ve selected a few @sanity/base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanity-io / sanity / packages / @sanity / desk-tool / src / utils / withInitialValue.js View on Github external
function resolveInitialValueWithParameters(templateName, parameters) {
  if (!templateExists(templateName)) {
    // eslint-disable-next-line no-console
    console.warn('Template "%s" not defined, using empty initial value', templateName)
    return of({isResolving: false, initialValue: undefined})
  }

  return from(resolveInitialValue(getTemplateById(templateName), parameters)).pipe(
    map(initialValue => ({isResolving: false, initialValue}))
  )
}