feat: gatsby source medusa (#924)

This commit is contained in:
Kasper Fabricius Kristensen
2021-12-14 20:56:31 +01:00
committed by GitHub
parent d0d8dd7bf6
commit b8ff364276
18 changed files with 12013 additions and 0 deletions
@@ -0,0 +1,25 @@
import { SourceNodesArgs } from "gatsby"
import { processNode } from "./process-node"
export function makeSourceFromOperation(gatsbyApi: SourceNodesArgs) {
return async function sourceFromOperation(
op: IMedusaOperation
): Promise<void> {
const { reporter, actions } = gatsbyApi
reporter.info(`Initiating operation query ${op.name}`)
const nodes = await op.execute()
nodes.map((rawNode) => {
const nodeArr = processNode(
rawNode,
op.name,
gatsbyApi.createContentDigest
)
nodeArr.forEach((node) => {
actions.createNode(node)
})
})
}
}