Skip to content

feat: decoupled sourcing PoC#561

Draft
ascorbic wants to merge 18 commits into
mainfrom
mk/merlin
Draft

feat: decoupled sourcing PoC#561
ascorbic wants to merge 18 commits into
mainfrom
mk/merlin

Conversation

@ascorbic

@ascorbic ascorbic commented Feb 10, 2023

Copy link
Copy Markdown
Contributor

Summary

PoC for experimental decoupled sourcing support. Test this by installing @netlify/plugin-gatsby@merlin and then setting the env vars GATSBY_CLOUD_DATALAYER, CONTENT_CLOUD_ID and RESOURCE_AUTH_JWT

Test plan

  1. Visit the Deploy Preview (insert link to specific page) ...

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was
published correctly.

@netlify

netlify Bot commented Feb 10, 2023

Copy link
Copy Markdown

Deploy Preview for netlify-plugin-gatsby-demo ready!

Name Link
🔨 Latest commit 71db642
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-gatsby-demo/deploys/63f4ed8a55c16a0008a4abe3
😎 Deploy Preview https://deploy-preview-561--netlify-plugin-gatsby-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Comment thread plugin/package.json Outdated
"prepare": "npm run build"
},
"dependencies": {
"@gatsby-cloud-pkg/merlin-synchronizer": "^0.3.6",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding it as a dep of the plugin should make it resolvable to builds, but we can do tests with auto-install using feature flags later

Comment on lines +33 to +37
if (
!process.env.GATSBY_CLOUD_DATALAYER ||
!process.env.GATSBY_SITE_ID ||
!process.env.SITE_AUTH_JWT
) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These currently need to be manually set

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of SITE_AUTH_JWT, can we make it RESOURCE_AUTH_JWT

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and instead of GATSBY_SITE_ID lets do CONTENT_CLOUD_ID

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SITE_AUTH_JWT is for merlin-synchronizer, so we'd need to change that module to allow either

* This file was copied from Gatsby core and modified and will be copied back into node_modules/gatsby when Netlify does a cold-cache build.
* See 'helpers/files.ts'
*/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This injected file is copied from the Gatsby repo with a few small changes to work on Netlify

return originalSourceNodesApiRunner.sourceNodesApiRunner(args)
}

const { synchronize } = require(`@gatsby-cloud-pkg/merlin-synchronizer`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to replace this with a full resolved path to the dependency if resolving from an auto-installed plugin fails

Comment thread plugin/src/templates/inject/source-nodes-api-runner.js
encoding: `string`,
}).init()

const siteId = process.env.GATSBY_SITE_ID

@abhiaiyer91 abhiaiyer91 Feb 10, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be CONTENT_CLOUD_ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants