Skip to content

API migration tips & tricks

Luna McNulty edited this page Oct 30, 2024 · 2 revisions

Start an in memory mongodb seeded database:

npm run start:memory-mongo

Build in M* Apple processors:

GATSBY_FUNCTIONS_PLATFORM=darwin GATSBY_FUNCTIONS_ARCH=arm64 gatsby build

Serve the app locally

npm run start

Obsolete: npm run serve

To reduce crashes:

NODE_OPTIONS=--max-old-space-size=18192 npm run start

Start an instance of the local API as a node server.

This will help you to:

  • write queries/mutations with suggestions
  • debug API fields
npm run start:api
Possible Errors

If you get an error like:

Error: Cannot find module '/<long path>/site/gatsby-site/ts-node/register'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

You may need to create a symlink to ts-node

cd site/gatsby-site/
ln -s ./node_modules/ts-node ts-node

Run API jest tests:

npm run test:api

Update graphQL schema types:

npm run codegen

Addenda

If using vscode it is highly recommended to install: