How to use the @sanity/schema.default function in @sanity/schema

To help you get started, we’ve selected a few @sanity/schema 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 / core / src / actions / graphql / extractFromSanitySchema.js View on Github external
const {uniqBy, startCase} = require('lodash')
const generateHelpUrl = require('@sanity/generate-help-url')
const schemaCompiler = require('@sanity/schema')
const oneline = require('oneline')
const helpUrls = require('./helpUrls')
const SchemaError = require('./SchemaError')

const Schema = schemaCompiler.default || schemaCompiler
const skipTypes = ['document', 'reference']
const allowedJsonTypes = ['object', 'array']
const disallowedCustomizedMembers = ['object', 'array', 'image', 'file', 'block']
const scalars = ['string', 'number', 'boolean']

function getBaseType(baseSchema, typeName) {
  return Schema.compile({
    types: baseSchema._original.types.concat([
      {name: `__placeholder__`, type: typeName, options: {hotspot: true}}
    ])
  }).get('__placeholder__')
}

function getTypeName(str) {
  const name = startCase(str).replace(/\s+/g, '')
  return name === 'Number' ? 'Float' : name