This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.time(`lmdb-init`) | |
const { open } = require("lmdb-store") | |
const store = open({ | |
name: `store`, | |
path: process.cwd() + `/test`, | |
}) | |
const db = store.openDB({ | |
name: `db`, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// node --expose-gc gc-test.js | |
// CACHE=1 node --expose-gc gc-test.js | |
const { open } = require("lmdb-store") | |
const ptop = require("process-top")() | |
let rootDb | |
function getRootDb() { | |
if (!rootDb) { | |
rootDb = open({ | |
name: `root`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const query = graphql` | |
{ | |
allFoo(filter: { foo: { eq: "foo" }}) { | |
nodes { | |
id | |
foo | |
fooBars @connect(field: "allBar", filter: { fooId: { eq: this__id } }) { | |
nodes { | |
bar | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.onPreInit = (gatsbyApi, pluginOptions) => {} | |
exports.sourceNodes = async (gatsbyApi) => { | |
const {cache, reporter} = gatsbyApi | |
reporter.info('Testing cache'); | |
reporter.info(await cache.get('test')); | |
reporter.info('Setting cache'); | |
await cache.set('test', 'someValue'); | |
reporter.info('Checking if set succesfully'); | |
reporter.info(await cache.get('test')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
mapleton: allFile(filter: { sourceInstanceName: { eq: "mapleton" } }) { | |
...FilesWithFluid | |
} | |
belair: allFile(filter: { sourceInstanceName: { eq: "belair" } }) { | |
...FilesWithFluid | |
} | |
robertsonTower: allFile( | |
filter: { sourceInstanceName: { eq: "robertson-tower" } } | |
) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function singularRootFieldName(queryFields, type) { | |
return Object.keys(queryFields).find(fieldName => queryFields[fieldName].type === type) | |
} | |
function pluralRootFieldName(queryFields, type) { | |
const expectedType = `[${type}!]!` | |
return Object.keys(queryFields).find(fieldName => String(queryFields[fieldName].type) === expectedType) | |
} | |
////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
wrapQueryExecutorWithQueue, | |
loadSchema, | |
generateDefaultFragments, | |
compileNodeQueries, | |
buildNodeDefinitions, | |
createSchemaCustomization, | |
sourceAllNodes, | |
sourceNodeChanges, | |
} = require('gatsby-graphql-source-toolkit') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.sourceNodes = async (gatsbyAPI, pluginOptions) => { | |
const config = await createSourcingConfig(gatsbyApi) | |
const { webhookBody } = gatsbyAPI | |
if (webhookBody && Object.keys(webhookBody).length) { | |
const { isDelete, typeName, id } = webhookBody | |
const nodeEvent = isDelete | |
? { | |
eventName: "DELETE", | |
remoteTypeName: typeName, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.onCreateNode = async ({ | |
node, | |
actions: { createNode }, | |
createNodeId, | |
getCache, | |
}) => { | |
if (node.remoteTypeName === 'Asset' && node.mimeType.includes('image/')) { | |
const fileNode = await createRemoteFileNode({ | |
url: node.url, | |
parentNodeId: node.id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/packages/gatsby-plugin-page-creator/src/derive-path.ts b/packages/gatsby-plugin-page-creator/src/derive-path.ts | |
index 4d7a2aa78..4c9070e2c 100644 | |
--- a/packages/gatsby-plugin-page-creator/src/derive-path.ts | |
+++ b/packages/gatsby-plugin-page-creator/src/derive-path.ts | |
@@ -5,7 +5,7 @@ import _ from "lodash" | |
// src/pages/product/{sku__en} => product/:sku__en pulls from nodes.sku.en | |
export function derivePath(path: string, node: Record<string, any>): string { | |
// 1. Remove the extension | |
- const pathWithoutExtension = path.replace(/\.[a-z]+$/, ``) | |
+ let pathWithoutExtension = path.replace(/\.[a-z]+$/, ``) |
NewerOlder