Last active
August 29, 2023 08:25
-
-
Save dac09/99cf500bbd5dc740a10c8cabf7372018 to your computer and use it in GitHub Desktop.
Revisions
-
dac09 revised this gist
Aug 29, 2023 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,6 @@ const rootDir = process.cwd() addExperimentalApolloPatch() addResolutionsToPackageJson({ '@apollo/[email protected]': 'patch:@apollo/experimental-nextjs-app-support@npm%3A0.4.1#./.yarn/patches/@apollo-experimental-nextjs-app-support-npm-0.4.1-de585a5c53.patch', }) -
dac09 revised this gist
Aug 23, 2023 . No changes.There are no files selected for viewing
-
dac09 revised this gist
Aug 23, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -80,6 +80,7 @@ index 28367f189dafc08a93a84e5008cc37ce919785b1..ad722c161550b4c0ca644c04166b4a7e console.log() console.log('~~~~ 🎉 ~~~~') console.log() console.log('Done! Run `yarn install`, and you should be good to go!') console.log() console.log('~~~~ 🎉 ~~~~') -
dac09 revised this gist
Aug 23, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -82,3 +82,5 @@ console.log() console.log('~~~~ 🎉 ~~~~') console.log('Done! Run `yarn install`, and you should be good to go!') console.log() console.log('~~~~ 🎉 ~~~~') -
dac09 revised this gist
Aug 23, 2023 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -78,4 +78,7 @@ index 28367f189dafc08a93a84e5008cc37ce919785b1..ad722c161550b4c0ca644c04166b4a7e }) } console.log() console.log('~~~~ 🎉 ~~~~') console.log('Done! Run `yarn install`, and you should be good to go!') console.log() -
dac09 revised this gist
Aug 23, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -78,4 +78,4 @@ index 28367f189dafc08a93a84e5008cc37ce919785b1..ad722c161550b4c0ca644c04166b4a7e }) } console.log('Done! Run `yarn install`') -
dac09 revised this gist
Aug 23, 2023 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ Run this on the root of your Redwood project, like this: ``` npx https://gist.github.com/dac09/99cf500bbd5dc740a10c8cabf7372018 ``` -
dac09 revised this gist
Aug 23, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -77,3 +77,5 @@ index 28367f189dafc08a93a84e5008cc37ce919785b1..ad722c161550b4c0ca644c04166b4a7e encoding: 'utf8', }) } -
dac09 revised this gist
Aug 23, 2023 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ { "name": "setup-cell-streaming-apollo", "version": "0.0.1", "bin": "./setupCellStreamingApollo.js" } -
dac09 created this gist
Aug 23, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,79 @@ #!/usr/bin/env node const fs = require('fs') const path = require('path') const process = require('process') const rootDir = process.cwd() addExperimentalApolloPatch() addResolutionsToPackageJson({ '@apollo/client': '3.8.1', '@apollo/[email protected]': 'patch:@apollo/experimental-nextjs-app-support@npm%3A0.4.1#./.yarn/patches/@apollo-experimental-nextjs-app-support-npm-0.4.1-de585a5c53.patch', }) function addResolutionsToPackageJson(resolutions) { const packageJsonPath = './package.json' // Read the package.json file const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) // Add the resolutions to the package.json file packageJson.resolutions = resolutions // Write the updated package.json file fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)) } function addExperimentalApolloPatch() { const filePath = path.join( rootDir, '.yarn', 'patches', '@apollo-experimental-nextjs-app-support-npm-0.4.1-de585a5c53.patch' ) const dirPath = path.dirname(filePath) const patchContent = `diff --git a/dist/ssr/RehydrationContext.js b/dist/ssr/RehydrationContext.js index 28367f189dafc08a93a84e5008cc37ce919785b1..ad722c161550b4c0ca644c04166b4a7e0703a2d8 100644 --- a/dist/ssr/RehydrationContext.js +++ b/dist/ssr/RehydrationContext.js @@ -7,7 +7,7 @@ exports.useRehydrationContext = exports.RehydrationContextProvider = void 0; const client_1 = require("@apollo/client"); const react_1 = __importDefault(require("react")); const NextSSRInMemoryCache_1 = require("./NextSSRInMemoryCache"); -const navigation_1 = require("next/navigation"); +const navigation_1 = require("@redwoodjs/web"); const dataTransport_1 = require("./dataTransport"); const ts_invariant_1 = __importDefault(require("ts-invariant")); const NextSSRApolloClient_1 = require("./NextSSRApolloClient"); @@ -40,7 +40,7 @@ const RehydrationContextProvider = ({ children, }) => { exports.RehydrationContextProvider = RehydrationContextProvider; function useRehydrationContext() { const rehydrationContext = react_1.default.useContext(ApolloRehydrationContext); - const insertHtml = react_1.default.useContext(navigation_1.ServerInsertedHTMLContext); + const insertHtml = react_1.default.useContext(navigation_1.ServerHtmlContext); // help transpilers to omit this code in bundling if (typeof window !== "undefined") return; @@ -54,6 +54,7 @@ function useRehydrationContext() { } exports.useRehydrationContext = useRehydrationContext; function buildApolloRehydrationContext() { + console.log('xxxxx buildApolloRehydrationContext') const rehydrationContext = { currentlyInjected: false, transportValueData: {}, ` // Create directory if it doesn't exist if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath, { recursive: true }) } // Create file if it doesn't exist and insert patch content fs.writeFileSync(filePath, patchContent, { encoding: 'utf8', }) }