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

To help you get started, we’ve selected a few gridsome 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 gridsome / gridsome / packages / source-contentful / lib / types / rich-text.js View on Github external
const { documentToHtmlString } = require('@contentful/rich-text-html-renderer')
const { GraphQLScalarType } = require('gridsome/graphql')

const ContentfulRichTextField = new GraphQLScalarType({
  name: 'ContentfulRichTextField',
  serialize: value => value
})

module.exports = options => ({
  type: ContentfulRichTextField,
  args: {
    html: { type: 'Boolean', defaultValue: false }
  },
  resolve (obj, args, context, info) {
    const value = obj[info.fieldName]

    const json = typeof value === 'string'
      ? JSON.parse(value)
      : null

gridsome

A JAMstack framework for building blazing fast websites with Vue.js

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis