JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13911
  • Score
    100M100P100Q136566F
  • License MIT

Gatsby node helper functions to aid node creation.

Package Exports

  • gatsby-node-helpers

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gatsby-node-helpers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gatsby-node-helpers

Gatsby node helper functions to aid node creation. To be used when creating [Gatsby source plugins][gatsby-source-plugins].

Status

npm version Build Status

Installation

npm install --save gatsby-node-helpers

Quick Guide

Import

Import the default module:

import createNodeHelpers from 'gatsby-node-helpers'

Create node helpers

import createNodeHelpers from 'gatsby-node-helpers'

const {
  createNodeFactory,
  generateNodeId,
  generateTypeName,
} = createNodeHelpers({
  typePrefix: `Shopify`,
})

Create a node factory

import createNodeHelpers from 'gatsby-node-helpers'

const {
  createNodeFactory,
  generateNodeId,
  generateTypeName,
} = createNodeHelpers({
  typePrefix: `Shopify`,
})

export const DocumentNode = createNodeFactory('DocumentNode')

Use the node factory in your gatsby-node.js

// gatsby-node.js

import { DocumentNode } from './nodes'
import { getAllDocuments } from './api'

const documents = getAllDocuments()

exports.sourceNodes = async ({ boundActionCreators }) => {
  const { createNode } = boundActionCreators

  const documents = await getAllDocuments()

  documents.forEach(document => {
    const node = DocumentNode(document)
    createNode(node)
  })
}

API

Coming soon...