Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Gql fragments support for prerender. Clean up crwa templates #9594

Merged
merged 60 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
65a4fe8
WIP to load possible types
dthyresson Nov 20, 2023
f9468ac
Vite plugin to setup possible types for apollo client cache config
dthyresson Nov 28, 2023
bfb2945
Build codegen files if needed for fragment/doc support
dthyresson Nov 28, 2023
5ca49c5
client present silences output
dthyresson Nov 28, 2023
60794b2
Doc typos
dthyresson Nov 30, 2023
2e7d678
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Nov 30, 2023
fb9aea7
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Dec 1, 2023
64e499e
Fix failing test to ensure graphql config is set
dthyresson Dec 1, 2023
a0ece41
CRWA JS template needed to be rebuilt
dthyresson Dec 1, 2023
ad5acab
Updated test project
dthyresson Dec 1, 2023
8f7d0c3
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Dec 9, 2023
64be78c
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Dec 11, 2023
f431b00
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Dec 12, 2023
a007bcd
Removes possible types from crwa and test fixture
dthyresson Dec 12, 2023
7bc0ec5
Fixes CRWA template tests to remove possible types
dthyresson Dec 12, 2023
b944d55
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Dec 13, 2023
38636e9
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Dec 13, 2023
562e1e9
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Dec 19, 2023
bc1bbe8
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Dec 20, 2023
8e2e674
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Dec 20, 2023
6337e97
Use a virtual module for possibleTypes
Tobbe Dec 20, 2023
a48a6b2
Update vite plugin doc comment
Tobbe Dec 20, 2023
0faee42
Respect toml config for trustedDocuments on/off
Tobbe Dec 20, 2023
67c92c4
Stop using rwConfig for perf reasons
Tobbe Dec 20, 2023
7773afe
Webpack support
Tobbe Dec 20, 2023
ca64fae
Use getConfigPath to benefit from caching
Tobbe Dec 20, 2023
2dc90a5
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Dec 27, 2023
7bd553c
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Dec 27, 2023
a09f5d9
Copy the possible types to dist to mimic virtual module when prerende…
dthyresson Dec 27, 2023
af359da
typo in graphql fragments
dthyresson Dec 27, 2023
9615b5c
Updates test fixtures
dthyresson Dec 28, 2023
00404f0
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Jan 3, 2024
f80abdd
Merge branch 'main' into dt-possible-types-dynamic
dthyresson Jan 3, 2024
323f716
the virtual possible types needs to be cjs when not using fragments a…
dthyresson Jan 3, 2024
1b2f980
rebuild test project fixture
Tobbe Jan 3, 2024
5b4bbe3
Remove comment
Tobbe Jan 3, 2024
a64e681
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Jan 3, 2024
a6063ee
Don't create new files in node_modules
Tobbe Jan 4, 2024
e2e27e4
prerender: Monkeypatch require to handle virtual-possibleTypes
Tobbe Jan 4, 2024
42b0296
storybook: possibleTypes
Tobbe Jan 4, 2024
0a4f0f1
add missing file
Tobbe Jan 4, 2024
25a9cd1
add vite plugin to RSC config
Tobbe Jan 4, 2024
f7180b4
jest
Tobbe Jan 4, 2024
f849b4b
Generate fragments test project
Tobbe Jan 5, 2024
4eb85f2
Update test-project fixture
Tobbe Jan 5, 2024
4eb3aed
Fragments smoke-test
Tobbe Jan 5, 2024
19220a9
Windows... (corepack issue)
Tobbe Jan 5, 2024
e363b31
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Jan 5, 2024
8cf1c9a
Run with test-project tasks with node
Tobbe Jan 5, 2024
6746a00
TS add-gql-fragments
Tobbe Jan 6, 2024
b3a56f9
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Jan 6, 2024
f4f6434
Script to rebuild fragments test project fixture
Tobbe Jan 6, 2024
7a547d8
Generate new fragment-test-project
Tobbe Jan 6, 2024
1671888
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Jan 6, 2024
0ee6b5f
Enable fragments for prerendering
Tobbe Jan 6, 2024
d0d51c6
web tests: map virtual-possibleTypes
Tobbe Jan 6, 2024
c1330ef
Try vite ssr noExternal for virtual-possibleTypes
Tobbe Jan 6, 2024
aa5c03f
Add virtual-possibleType support for SSR
Tobbe Jan 7, 2024
de8923f
Merge branch 'main' into dt-possible-types-dynamic
Tobbe Jan 7, 2024
fb35854
Remove virtual possibleTypes module
Tobbe Jan 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -702,6 +702,96 @@ jobs:
steps:
- run: echo "Skipped"

fragments-smoke-tests:
needs: check

strategy:
matrix:
os: [ubuntu-latest, windows-latest]

name: 📄 Fragments Smoke tests / ${{ matrix.os }}
runs-on: ${{ matrix.os }}

env:
REDWOOD_CI: 1
REDWOOD_VERBOSE_TELEMETRY: 1

steps:
- uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: ⬢ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Enable Corepack
run: corepack enable

- name: 🐈 Set up yarn cache
uses: ./.github/actions/set-up-yarn-cache

- name: 🐈 Yarn install
run: yarn install --inline-builds
env:
GITHUB_TOKEN: ${{ github.token }}

- name: 🔨 Build
run: yarn build

- name: 🌲 Set up test project
id: set-up-test-project
uses: ./.github/actions/set-up-test-project
with:
bundler: vite
canary: true
env:
REDWOOD_DISABLE_TELEMETRY: 1
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Run Fragments codemods on test project
run: npx -y tsx ./tasks/test-project/add-gql-fragments ${{ steps.set-up-test-project.outputs.test-project-path }}
env:
REDWOOD_DISABLE_TELEMETRY: 1

- name: 🎭 Install playwright dependencies
run: npx playwright install --with-deps chromium

- name: Run Fragments dev smoke tests
working-directory: ./tasks/smoke-tests/fragments-dev
run: npx playwright test
env:
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
REDWOOD_DISABLE_TELEMETRY: 1

- name: Build for production
working-directory: ${{ steps.set-up-test-project.outputs.test-project-path }}
run: yarn rw build
env:
REDWOOD_DISABLE_TELEMETRY: 1

- name: Run Fragments serve smoke tests
working-directory: ./tasks/smoke-tests/fragments-serve
run: npx playwright test
env:
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
REDWOOD_DISABLE_TELEMETRY: 1

fragments-smoke-tests-skip:
needs: detect-changes

strategy:
matrix:
os: [ubuntu-latest, windows-latest]

name: 📄 Fragments Smoke tests / ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- run: echo "Skipped"

crwa:
needs: check

19 changes: 19 additions & 0 deletions __fixtures__/fragment-test-project/.env.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# These environment variables will be used by default if you do not create any
# yourself in .env. This file should be safe to check into your version control
# system. Any custom values should go in .env and .env should *not* be checked
# into version control.

# schema.prisma defaults
DATABASE_URL=file:./dev.db

# location of the test database for api service scenarios (defaults to ./.redwood/test.db if not set)
# TEST_DATABASE_URL=file:./.redwood/test.db

# disables Prisma CLI update notifier
PRISMA_HIDE_UPDATE_MESSAGE=true

# Option to override the current environment's default api-side log level
# See: https://redwoodjs.com/docs/logger for level options, defaults to "trace" otherwise.
# Most applications want "debug" or "info" during dev, "trace" when you have issues and "warn" in production.
# Ordered by how verbose they are: trace | debug | info | warn | error | silent
# LOG_LEVEL=debug
4 changes: 4 additions & 0 deletions __fixtures__/fragment-test-project/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# DATABASE_URL=file:./dev.db
# TEST_DATABASE_URL=file:./.redwood/test.db
# PRISMA_HIDE_UPDATE_MESSAGE=true
# LOG_LEVEL=trace
22 changes: 22 additions & 0 deletions __fixtures__/fragment-test-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.idea
.DS_Store
.env
.netlify
.redwood/*
!.redwood/README.md
dev.db*
dist
dist-babel
node_modules
yarn-error.log
web/public/mockServiceWorker.js
web/types/graphql.d.ts
api/types/graphql.d.ts
api/src/lib/generateGraphiQLHeader.*
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
44 changes: 44 additions & 0 deletions __fixtures__/fragment-test-project/.redwood/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .redwood

## What is this directory?

Redwood uses this `.redwood` directory to store transitory data that aids in the smooth and convenient operation of your Redwood project.

## Do I need to do anything with this directory?

No. You shouldn't have to create, edit or delete anything in this directory in your day-to-day work with Redwood.

You don't need to commit any other contents of this directory to your version control system. It's ignored by default.

## What's in this directory?

### Files

| Name | Description |
| :---------------- | :------- |
| commandCache.json | This file contains mappings to assist the Redwood CLI in efficiently executing commands. |
| schema.graphql | This is the GraphQL schema which has been automatically generated from your Redwood project. |
| studio.db | The sqlite database used by the experimental `rw exp studio` feature. |
| telemetry.txt | Contains a unique ID used for telemetry. This value is rotated every 24 hours to protect your project's anonymity. |
| test.db | The sqlite database used when running tests. |

### Directories

| Name | Description |
| :---------- | :------- |
| locks | Stores temporary files that Redwood uses to keep track of the execution of async/background tasks between processes. |
| logs | Stores log files for background tasks such as update checking. |
| prebuild | Stores transpiled JavaScript that is generated as part of Redwood's build process. |
| telemetry | Stores the recent telemetry that the Redwood CLI has generated. You may inspect these files to see everything Redwood is anonymously collecting. |
| types | Stores the results of type generation. |
| updateCheck | Stores a file which contains the results of checking for Redwood updates. |

We try to keep this README up to date but you may, from time to time, find other files or directories in this `.redwood` directory that have not yet been documented here. This is likely nothing to worry about but feel free to let us know and we'll update this list.

### Telemetry

RedwoodJS collects completely anonymous telemetry data about general usage. For transparency, that data is viewable in the respective directories and files. To learn more and manage your project's settings, visit [telemetry.redwoodjs.com](https://telemetry.redwoodjs.com).

### Have any questions?

Feel free to reach out to us in the [RedwoodJS Community](https://community.redwoodjs.com/) forum if you have any questions.
102 changes: 0 additions & 102 deletions __fixtures__/fragment-test-project/.redwood/schema.graphql

This file was deleted.

16 changes: 16 additions & 0 deletions __fixtures__/fragment-test-project/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"ofhumanbondage.react-proptypes-intellisense",
"mgmcdermott.vscode-language-babel",
"wix.vscode-import-cost",
"pflannery.vscode-versionlens",
"editorconfig.editorconfig",
"prisma.prisma",
"graphql.vscode-graphql",
"csstools.postcss",
"bradlc.vscode-tailwindcss"
],
"unwantedRecommendations": []
}
56 changes: 56 additions & 0 deletions __fixtures__/fragment-test-project/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"version": "0.3.0",
"configurations": [
{
"command": "yarn redwood dev --apiDebugPort 18911", // you can add --fwd='--open=false' to prevent the browser from opening
"name": "Run Dev Server",
"request": "launch",
"type": "node-terminal"
},
{
"name": "Attach API debugger",
"port": 18911, // you can change this port, see https://redwoodjs.com/docs/project-configuration-dev-test-build#debugger-configuration
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"localRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist",
"remoteRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist",
"sourceMaps": true,
"restart": true,
"preLaunchTask": "WaitForDevServer",
},
{
"name": "Launch Web debugger",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8910",
"webRoot": "${workspaceRoot}/web/src",
"preLaunchTask": "WaitForDevServer",
},
{
"command": "yarn redwood test api",
"name": "Test api",
"request": "launch",
"type": "node-terminal"
},
{
"command": "yarn redwood test web",
"name": "Test web",
"request": "launch",
"type": "node-terminal"
},
],
"compounds": [
{
"name": "Start Debug",
"configurations": [
"Run Dev Server",
"Attach API debugger",
"Launch Web debugger"
],
"stopAll": true
}
]
}
11 changes: 11 additions & 0 deletions __fixtures__/fragment-test-project/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"editor.tabSize": 2,
"files.trimTrailingWhitespace": true,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"[prisma]": {
"editor.formatOnSave": true
}
}
Loading