How to use the gatsby/graphql.GraphQLEnumType 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 sanity-io / gatsby-source-sanity / src / images / extendImageNode.ts View on Github external
GraphQLEnumType,
} from 'gatsby/graphql'
import {GatsbyContext, GatsbyOnNodeTypeContext} from '../types/gatsby'
import {PluginConfig} from '../gatsby-node'
import {
  getFixedGatsbyImage,
  getFluidGatsbyImage,
  ImageNode,
  FixedArgs,
  FluidArgs,
  DEFAULT_FLUID_MAX_WIDTH,
  DEFAULT_FIXED_WIDTH,
} from './getGatsbyImageProps'
import {getCacheKey, CACHE_KEYS} from '../util/cache'

const ImageFormatType = new GraphQLEnumType({
  name: 'SanityImageFormat',
  values: {
    NO_CHANGE: {value: ''},
    JPG: {value: 'jpg'},
    PNG: {value: 'png'},
    WEBP: {value: 'webp'},
  },
})

const extensions = new Map()

export function extendImageNode(
  context: GatsbyContext & GatsbyOnNodeTypeContext,
  config: PluginConfig,
): {[key: string]: GraphQLFieldConfig} {
  const key = getCacheKey(config, CACHE_KEYS.IMAGE_EXTENSIONS)
github ChristopherBiscardi / gatsby-mdx / packages / gatsby-mdx / gatsby / extend-node-type.js View on Github external
fields: {
        value: {
          type: GraphQLString,
          resolve(heading) {
            return heading.value;
          }
        },
        depth: {
          type: GraphQLInt,
          resolve(heading) {
            return heading.depth;
          }
        }
      }
    });
    const Headings = new GraphQLEnumType({
      name: `HeadingsMdx`,
      values: {
        h1: { value: 1 },
        h2: { value: 2 },
        h3: { value: 3 },
        h4: { value: 4 },
        h5: { value: 5 },
        h6: { value: 6 }
      }
    });

    return resolve({
      code: {
        resolve(mdxNode) {
          return mdxNode;
        },