feat: gatsby source medusa (#924)
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user