How to use the gatsby/graphql.GraphQLScalarType function in gatsby

To help you get started, we’ve selected a few gatsby 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 angeloashmore / gatsby-source-prismic / src / customTypeJsonToGraphQLSchema.js View on Github external
GraphQLScalarType,
  GraphQLSchema,
  GraphQLString,
  GraphQLUnionType,
} from 'gatsby/graphql'
import pascalcase from 'pascalcase'

const _generateTypeName = joinChar => (...parts) =>
  ['Prismic', ...parts.map(pascalcase)].join(joinChar)
const generatePublicTypeName = _generateTypeName('')
const generateNamespacedTypeName = _generateTypeName('__')

// Provides the ability to control the return value of Date fields on the
// mocked node. This is required to ensure Gatsby processes the field as a Date
// to provide date arguments like `formatString`.
const GraphQLDate = new GraphQLScalarType({
  name: 'Date',
  serialize: R.identity,
})

// Provides the ability to control the return value of ImageURL fields on the
// mocked node. This is required to allow setting the image URL when creating
// mock localFile fields.
const GraphQLImageURL = new GraphQLScalarType({
  name: 'ImageURL',
  serialize: R.identity,
})

const GraphQLPrismicHTML = new GraphQLObjectType({
  name: generateNamespacedTypeName('HTML'),
  fields: {
    html: { type: new GraphQLNonNull(GraphQLString) },
github angeloashmore / gatsby-source-prismic / src / customTypeJsonToGraphQLSchema.js View on Github external
['Prismic', ...parts.map(pascalcase)].join(joinChar)
const generatePublicTypeName = _generateTypeName('')
const generateNamespacedTypeName = _generateTypeName('__')

// Provides the ability to control the return value of Date fields on the
// mocked node. This is required to ensure Gatsby processes the field as a Date
// to provide date arguments like `formatString`.
const GraphQLDate = new GraphQLScalarType({
  name: 'Date',
  serialize: R.identity,
})

// Provides the ability to control the return value of ImageURL fields on the
// mocked node. This is required to allow setting the image URL when creating
// mock localFile fields.
const GraphQLImageURL = new GraphQLScalarType({
  name: 'ImageURL',
  serialize: R.identity,
})

const GraphQLPrismicHTML = new GraphQLObjectType({
  name: generateNamespacedTypeName('HTML'),
  fields: {
    html: { type: new GraphQLNonNull(GraphQLString) },
    text: { type: new GraphQLNonNull(GraphQLString) },
  },
})

const GraphQLPrismicGeoPoint = new GraphQLObjectType({
  name: generateNamespacedTypeName('GeoPoint'),
  fields: {
    latitude: { type: new GraphQLNonNull(GraphQLFloat) },