diff --git a/.github/actions/check_create_redwood_app/package.json b/.github/actions/check_create_redwood_app/package.json index 03bc407905ca..59de5a44a1d2 100644 --- a/.github/actions/check_create_redwood_app/package.json +++ b/.github/actions/check_create_redwood_app/package.json @@ -5,5 +5,5 @@ "@actions/core": "1.10.1", "@actions/exec": "1.1.1" }, - "packageManager": "yarn@4.0.2" + "packageManager": "yarn@4.1.0" } diff --git a/.github/actions/check_create_redwood_app/yarn.lock b/.github/actions/check_create_redwood_app/yarn.lock index 67423743c42c..1dc8c15feb05 100644 --- a/.github/actions/check_create_redwood_app/yarn.lock +++ b/.github/actions/check_create_redwood_app/yarn.lock @@ -11,7 +11,7 @@ __metadata: dependencies: "@actions/http-client": "npm:^2.0.1" uuid: "npm:^8.3.2" - checksum: 8c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832 + checksum: 10c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832 languageName: node linkType: hard @@ -20,7 +20,7 @@ __metadata: resolution: "@actions/exec@npm:1.1.1" dependencies: "@actions/io": "npm:^1.0.1" - checksum: 8c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a + checksum: 10c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a languageName: node linkType: hard @@ -29,14 +29,14 @@ __metadata: resolution: "@actions/http-client@npm:2.0.1" dependencies: tunnel: "npm:^0.0.6" - checksum: 8c0/b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67 + checksum: 10c0/b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67 languageName: node linkType: hard "@actions/io@npm:^1.0.1": version: 1.1.2 resolution: "@actions/io@npm:1.1.2" - checksum: 8c0/61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1 + checksum: 10c0/61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1 languageName: node linkType: hard @@ -52,7 +52,7 @@ __metadata: "tunnel@npm:^0.0.6": version: 0.0.6 resolution: "tunnel@npm:0.0.6" - checksum: 8c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75 + checksum: 10c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75 languageName: node linkType: hard @@ -61,6 +61,6 @@ __metadata: resolution: "uuid@npm:8.3.2" bin: uuid: dist/bin/uuid - checksum: 8c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54 + checksum: 10c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54 languageName: node linkType: hard diff --git a/.github/actions/detect-changes/package.json b/.github/actions/detect-changes/package.json index e3eddcdb1965..5a35d439d00e 100644 --- a/.github/actions/detect-changes/package.json +++ b/.github/actions/detect-changes/package.json @@ -5,5 +5,5 @@ "@actions/core": "1.10.1", "@actions/exec": "1.1.1" }, - "packageManager": "yarn@4.0.2" + "packageManager": "yarn@4.1.0" } diff --git a/.github/actions/detect-changes/yarn.lock b/.github/actions/detect-changes/yarn.lock index d92f30d6019d..12f7d4df7433 100644 --- a/.github/actions/detect-changes/yarn.lock +++ b/.github/actions/detect-changes/yarn.lock @@ -11,7 +11,7 @@ __metadata: dependencies: "@actions/http-client": "npm:^2.0.1" uuid: "npm:^8.3.2" - checksum: 7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832 + checksum: 10c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832 languageName: node linkType: hard @@ -20,7 +20,7 @@ __metadata: resolution: "@actions/exec@npm:1.1.1" dependencies: "@actions/io": "npm:^1.0.1" - checksum: 4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a + checksum: 10c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a languageName: node linkType: hard @@ -29,14 +29,14 @@ __metadata: resolution: "@actions/http-client@npm:2.0.1" dependencies: tunnel: "npm:^0.0.6" - checksum: b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67 + checksum: 10c0/b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67 languageName: node linkType: hard "@actions/io@npm:^1.0.1": version: 1.1.2 resolution: "@actions/io@npm:1.1.2" - checksum: 61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1 + checksum: 10c0/61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1 languageName: node linkType: hard @@ -52,7 +52,7 @@ __metadata: "tunnel@npm:^0.0.6": version: 0.0.6 resolution: "tunnel@npm:0.0.6" - checksum: e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75 + checksum: 10c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75 languageName: node linkType: hard @@ -61,6 +61,6 @@ __metadata: resolution: "uuid@npm:8.3.2" bin: uuid: dist/bin/uuid - checksum: bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54 + checksum: 10c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54 languageName: node linkType: hard diff --git a/.github/renovate.json b/.github/renovate.json index 3aa6fbfd133d..56c54a889e15 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -62,6 +62,15 @@ "sort-package-json", "zx" ] + }, + + { + "groupName": "experimental", + "enabled": false, + + "matchPackageNames": [ + "@apollo/experimental-nextjs-app-support" + ] } ] } diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/.redwood/README.md b/__fixtures__/test-project-rsc-external-packages-and-cells/.redwood/README.md index f22b586a47cc..8829edb84776 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/.redwood/README.md +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/.redwood/README.md @@ -18,7 +18,6 @@ You don't need to commit any other contents of this directory to your version co | :---------------- | :------- | | 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. | @@ -32,6 +31,7 @@ You don't need to commit any other contents of this directory to your version co | 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. | +| studio | Used to store data for `rw studio` | 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. diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/.vscode/launch.json b/__fixtures__/test-project-rsc-external-packages-and-cells/.vscode/launch.json index ea5956966fff..340be43c34da 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/.vscode/launch.json +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/.vscode/launch.json @@ -2,7 +2,7 @@ "version": "0.3.0", "configurations": [ { - "command": "yarn redwood dev --apiDebugPort 18911", + "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" @@ -18,7 +18,16 @@ "localRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist", "remoteRoot": "${workspaceFolder}/node_modules/@redwoodjs/api-server/dist", "sourceMaps": true, - "restart": 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", @@ -32,5 +41,16 @@ "request": "launch", "type": "node-terminal" }, + ], + "compounds": [ + { + "name": "Start Debug", + "configurations": [ + "Run Dev Server", + "Attach API debugger", + "Launch Web debugger" + ], + "stopAll": true + } ] } diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/.vscode/tasks.json b/__fixtures__/test-project-rsc-external-packages-and-cells/.vscode/tasks.json new file mode 100644 index 000000000000..549249ec6324 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "WaitForDevServer", + "group": "none", + "type": "shell", + "command": "bash", + "args": [ + "-c", + "while ! echo -n > /dev/tcp/localhost/18911; do sleep 1; done;" + ], + "windows": { + "command": "powershell", + "args": [ + "-NoProfile", + "-ExecutionPolicy", "Bypass", + "while (-not (Test-NetConnection -ComputerName localhost -Port 18911)) { Start-Sleep -Seconds 1 };" + ] + }, + "presentation": { + "reveal": "silent", + "revealProblems": "onProblem", + "panel": "shared", + "close": true + } + }, + ] +} diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/dev.db b/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/dev.db index a6912d6c19c2..bcc8cda86ca8 100644 Binary files a/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/dev.db and b/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/dev.db differ diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/migrations/20240212134007_empty_user/migration.sql b/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/migrations/20240212134007_empty_user/migration.sql new file mode 100644 index 000000000000..3c29dc91d808 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/migrations/20240212134007_empty_user/migration.sql @@ -0,0 +1,9 @@ +-- CreateTable +CREATE TABLE "EmptyUser" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "email" TEXT NOT NULL, + "name" TEXT +); + +-- CreateIndex +CREATE UNIQUE INDEX "EmptyUser_email_key" ON "EmptyUser"("email"); diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/schema.prisma b/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/schema.prisma index 3dea71a68f23..e82dee06da4a 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/schema.prisma +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/db/schema.prisma @@ -1,3 +1,9 @@ +// Don't forget to tell Prisma about your edits to this file using +// `yarn rw prisma migrate dev` or `yarn rw prisma db push`. +// `migrate` is like committing while `push` is for prototyping. +// Read more about both here: +// https://www.prisma.io/docs/orm/prisma-migrate + datasource db { provider = "sqlite" url = env("DATABASE_URL") @@ -16,3 +22,9 @@ model UserExample { email String @unique name String? } + +model EmptyUser { + id Int @id @default(autoincrement()) + email String @unique + name String? +} diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/package.json b/__fixtures__/test-project-rsc-external-packages-and-cells/api/package.json index 643edd217b4b..fa2cdc33e721 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/api/package.json +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "dependencies": { - "@redwoodjs/api": "7.0.0-canary.981", - "@redwoodjs/graphql-server": "7.0.0-canary.981" + "@redwoodjs/api": "7.0.0-canary.993", + "@redwoodjs/graphql-server": "7.0.0-canary.993" } } diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/graphql/emptyUsers.sdl.ts b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/graphql/emptyUsers.sdl.ts new file mode 100644 index 000000000000..14e3879255b1 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/graphql/emptyUsers.sdl.ts @@ -0,0 +1,29 @@ +export const schema = gql` + type EmptyUser { + id: Int! + email: String! + name: String + } + + type Query { + emptyUsers: [EmptyUser!]! @requireAuth + emptyUser(id: Int!): EmptyUser @requireAuth + } + + input CreateEmptyUserInput { + email: String! + name: String + } + + input UpdateEmptyUserInput { + email: String + name: String + } + + type Mutation { + createEmptyUser(input: CreateEmptyUserInput!): EmptyUser! @requireAuth + updateEmptyUser(id: Int!, input: UpdateEmptyUserInput!): EmptyUser! + @requireAuth + deleteEmptyUser(id: Int!): EmptyUser! @requireAuth + } +` diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/lib/auth.ts b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/lib/auth.ts index f98fe93a960c..4b0b88784d47 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/lib/auth.ts +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/lib/auth.ts @@ -23,3 +23,10 @@ export const hasRole = ({ roles }) => { export const requireAuth = ({ roles }) => { return isAuthenticated() } + +export const getCurrentUser = async () => { + throw new Error( + 'Auth is not set up yet. See https://redwoodjs.com/docs/authentication ' + + 'to get started' + ) +} diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.scenarios.ts b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.scenarios.ts new file mode 100644 index 000000000000..f0edd8a561e8 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.scenarios.ts @@ -0,0 +1,11 @@ +import type { Prisma, EmptyUser } from '@prisma/client' +import type { ScenarioData } from '@redwoodjs/testing/api' + +export const standard = defineScenario({ + emptyUser: { + one: { data: { email: 'String5770021' } }, + two: { data: { email: 'String5278315' } }, + }, +}) + +export type StandardScenario = ScenarioData diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.test.ts b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.test.ts new file mode 100644 index 000000000000..2a7c46b22084 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.test.ts @@ -0,0 +1,59 @@ +import type { EmptyUser } from '@prisma/client' + +import { + emptyUsers, + emptyUser, + createEmptyUser, + updateEmptyUser, + deleteEmptyUser, +} from './emptyUsers' +import type { StandardScenario } from './emptyUsers.scenarios' + +// Generated boilerplate tests do not account for all circumstances +// and can fail without adjustments, e.g. Float. +// Please refer to the RedwoodJS Testing Docs: +// https://redwoodjs.com/docs/testing#testing-services +// https://redwoodjs.com/docs/testing#jest-expect-type-considerations + +describe('emptyUsers', () => { + scenario('returns all emptyUsers', async (scenario: StandardScenario) => { + const result = await emptyUsers() + + expect(result.length).toEqual(Object.keys(scenario.emptyUser).length) + }) + + scenario('returns a single emptyUser', async (scenario: StandardScenario) => { + const result = await emptyUser({ id: scenario.emptyUser.one.id }) + + expect(result).toEqual(scenario.emptyUser.one) + }) + + scenario('creates a emptyUser', async () => { + const result = await createEmptyUser({ + input: { email: 'String8450568' }, + }) + + expect(result.email).toEqual('String8450568') + }) + + scenario('updates a emptyUser', async (scenario: StandardScenario) => { + const original = (await emptyUser({ + id: scenario.emptyUser.one.id, + })) as EmptyUser + const result = await updateEmptyUser({ + id: original.id, + input: { email: 'String82168002' }, + }) + + expect(result.email).toEqual('String82168002') + }) + + scenario('deletes a emptyUser', async (scenario: StandardScenario) => { + const original = (await deleteEmptyUser({ + id: scenario.emptyUser.one.id, + })) as EmptyUser + const result = await emptyUser({ id: original.id }) + + expect(result).toEqual(null) + }) +}) diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.ts b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.ts new file mode 100644 index 000000000000..382f3586e71f --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/src/services/emptyUsers/emptyUsers.ts @@ -0,0 +1,39 @@ +import type { QueryResolvers, MutationResolvers } from 'types/graphql' + +import { db } from 'src/lib/db' + +export const emptyUsers: QueryResolvers['emptyUsers'] = () => { + return db.emptyUser.findMany() +} + +export const emptyUser: QueryResolvers['emptyUser'] = ({ id }) => { + return db.emptyUser.findUnique({ + where: { id }, + }) +} + +export const createEmptyUser: MutationResolvers['createEmptyUser'] = ({ + input, +}) => { + return db.emptyUser.create({ + data: input, + }) +} + +export const updateEmptyUser: MutationResolvers['updateEmptyUser'] = ({ + id, + input, +}) => { + return db.emptyUser.update({ + data: input, + where: { id }, + }) +} + +export const deleteEmptyUser: MutationResolvers['deleteEmptyUser'] = ({ + id, +}) => { + return db.emptyUser.delete({ + where: { id }, + }) +} diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/api/tsconfig.json b/__fixtures__/test-project-rsc-external-packages-and-cells/api/tsconfig.json index fcbbf9872e43..a3a4bcdf5b58 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/api/tsconfig.json +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/api/tsconfig.json @@ -7,7 +7,6 @@ "module": "esnext", "moduleResolution": "node", "skipLibCheck": false, - "baseUrl": "./", "rootDirs": [ "./src", "../.redwood/types/mirror/api/src" diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/graphql.config.js b/__fixtures__/test-project-rsc-external-packages-and-cells/graphql.config.js index 2da7862f6b57..c564451acb66 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/graphql.config.js +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/graphql.config.js @@ -1,5 +1,11 @@ -const { getPaths } = require('@redwoodjs/internal') +// This file is used by the VSCode GraphQL extension -module.exports = { +const { getPaths } = require('@redwoodjs/project-config') + +/** @type {import('graphql-config').IGraphQLConfig} */ +const config = { schema: getPaths().generated.schema, + documents: './web/src/**/!(*.d).{ts,tsx,js,jsx}', } + +module.exports = config diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/package.json b/__fixtures__/test-project-rsc-external-packages-and-cells/package.json index a907102034dd..69d912133b5c 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/package.json +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/package.json @@ -7,7 +7,8 @@ ] }, "devDependencies": { - "@redwoodjs/core": "7.0.0-canary.981" + "@redwoodjs/core": "7.0.0-canary.993", + "@redwoodjs/project-config": "7.0.0-canary.993" }, "eslintConfig": { "extends": "@redwoodjs/eslint-config", @@ -19,5 +20,5 @@ "prisma": { "seed": "yarn rw exec seed" }, - "packageManager": "yarn@4.0.2" + "packageManager": "yarn@4.1.0" } diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/scripts/tsconfig.json b/__fixtures__/test-project-rsc-external-packages-and-cells/scripts/tsconfig.json index babc7c436be6..1e6487a5ffa6 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/scripts/tsconfig.json +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/scripts/tsconfig.json @@ -6,7 +6,6 @@ "target": "esnext", "module": "esnext", "moduleResolution": "node", - "baseUrl": "./", "paths": { "$api/*": [ "../api/*" diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/package.json b/__fixtures__/test-project-rsc-external-packages-and-cells/web/package.json index 252d7d499d33..1bdede320657 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/web/package.json +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/package.json @@ -11,9 +11,10 @@ ] }, "dependencies": { - "@redwoodjs/forms": "7.0.0-canary.981", - "@redwoodjs/router": "7.0.0-canary.981", - "@redwoodjs/web": "7.0.0-canary.981", + "@apollo/experimental-nextjs-app-support": "0.0.0-commit-b8a73fe", + "@redwoodjs/forms": "7.0.0-canary.993", + "@redwoodjs/router": "7.0.0-canary.993", + "@redwoodjs/web": "7.0.0-canary.993", "@tobbe.dev/rsc-test": "0.0.3", "client-only": "0.0.1", "react": "0.0.0-experimental-e5205658f-20230913", @@ -21,7 +22,7 @@ "server-only": "0.0.1" }, "devDependencies": { - "@redwoodjs/vite": "7.0.0-canary.981", + "@redwoodjs/vite": "7.0.0-canary.993", "@types/react": "^18.2.55", "@types/react-dom": "^18.2.19" } diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/Routes.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/Routes.tsx index 19e058bd2eec..4e50de9a0dec 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/Routes.tsx +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/Routes.tsx @@ -17,15 +17,24 @@ import NotFoundPage from './pages/NotFoundPage/NotFoundPage' const AboutPage = serve('AboutPage') const HomePage = serve('HomePage') const UserExampleUserExamplesPage = serve('UserExampleUserExamplesPage') +const UserExampleUserExamplePage = serve('UserExampleUserExamplePage') const UserExampleNewUserExamplePage = serve('UserExampleNewUserExamplePage') +const EmptyUserEmptyUsersPage = serve('EmptyUserEmptyUsersPage') +const EmptyUserNewEmptyUserPage = serve('EmptyUserNewEmptyUserPage') const Routes = () => { return ( + + + {/* + */} + + - {/* - */} + {/* */} + diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EditEmptyUserCell/EditEmptyUserCell.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EditEmptyUserCell/EditEmptyUserCell.tsx new file mode 100644 index 000000000000..bc63812f849d --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EditEmptyUserCell/EditEmptyUserCell.tsx @@ -0,0 +1,85 @@ +import type { + EditEmptyUserById, + UpdateEmptyUserInput, + UpdateEmptyUserMutationVariables, +} from 'types/graphql' + +import { navigate, routes } from '@redwoodjs/router' +import type { + CellSuccessProps, + CellFailureProps, + TypedDocumentNode, +} from '@redwoodjs/web' +import { useMutation } from '@redwoodjs/web' +import { toast } from '@redwoodjs/web/toast' + +import EmptyUserForm from 'src/components/EmptyUser/EmptyUserForm' + +export const QUERY: TypedDocumentNode = gql` + query EditEmptyUserById($id: Int!) { + emptyUser: emptyUser(id: $id) { + id + email + name + } + } +` + +const UPDATE_EMPTY_USER_MUTATION: TypedDocumentNode< + EditEmptyUserById, + UpdateEmptyUserMutationVariables +> = gql` + mutation UpdateEmptyUserMutation($id: Int!, $input: UpdateEmptyUserInput!) { + updateEmptyUser(id: $id, input: $input) { + id + email + name + } + } +` + +export const Loading = () =>
Loading...
+ +export const Failure = ({ error }: CellFailureProps) => ( +
{error?.message}
+) + +export const Success = ({ emptyUser }: CellSuccessProps) => { + const [updateEmptyUser, { loading, error }] = useMutation( + UPDATE_EMPTY_USER_MUTATION, + { + onCompleted: () => { + toast.success('EmptyUser updated') + navigate(routes.emptyUsers()) + }, + onError: (error) => { + toast.error(error.message) + }, + } + ) + + const onSave = ( + input: UpdateEmptyUserInput, + id: EditEmptyUserById['emptyUser']['id'] + ) => { + updateEmptyUser({ variables: { id, input } }) + } + + return ( +
+
+

+ Edit EmptyUser {emptyUser?.id} +

+
+
+ +
+
+ ) +} diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUser/EmptyUser.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUser/EmptyUser.tsx new file mode 100644 index 000000000000..cdcbe139f90e --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUser/EmptyUser.tsx @@ -0,0 +1,90 @@ +import type { + DeleteEmptyUserMutation, + DeleteEmptyUserMutationVariables, + FindEmptyUserById, +} from 'types/graphql' + +import { Link, routes, navigate } from '@redwoodjs/router' +import { useMutation } from '@redwoodjs/web' +import type { TypedDocumentNode } from '@redwoodjs/web' +import { toast } from '@redwoodjs/web/toast' + +import {} from 'src/lib/formatters' + +const DELETE_EMPTY_USER_MUTATION: TypedDocumentNode< + DeleteEmptyUserMutation, + DeleteEmptyUserMutationVariables +> = gql` + mutation DeleteEmptyUserMutation($id: Int!) { + deleteEmptyUser(id: $id) { + id + } + } +` + +interface Props { + emptyUser: NonNullable +} + +const EmptyUser = ({ emptyUser }: Props) => { + const [deleteEmptyUser] = useMutation(DELETE_EMPTY_USER_MUTATION, { + onCompleted: () => { + toast.success('EmptyUser deleted') + navigate(routes.emptyUsers()) + }, + onError: (error) => { + toast.error(error.message) + }, + }) + + const onDeleteClick = (id: DeleteEmptyUserMutationVariables['id']) => { + if (confirm('Are you sure you want to delete emptyUser ' + id + '?')) { + deleteEmptyUser({ variables: { id } }) + } + } + + return ( + <> +
+
+

+ EmptyUser {emptyUser.id} Detail +

+
+ + + + + + + + + + + + + + + +
Id{emptyUser.id}
Email{emptyUser.email}
Name{emptyUser.name}
+
+ + + ) +} + +export default EmptyUser diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUserCell/EmptyUserCell.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUserCell/EmptyUserCell.tsx new file mode 100644 index 000000000000..fadaeaffc92c --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUserCell/EmptyUserCell.tsx @@ -0,0 +1,41 @@ +import type { + FindEmptyUserById, + FindEmptyUserByIdVariables, +} from 'types/graphql' + +import type { + CellSuccessProps, + CellFailureProps, + TypedDocumentNode, +} from '@redwoodjs/web' + +import EmptyUser from 'src/components/EmptyUser/EmptyUser' + +export const QUERY: TypedDocumentNode< + FindEmptyUserById, + FindEmptyUserByIdVariables +> = gql` + query FindEmptyUserById($id: Int!) { + emptyUser: emptyUser(id: $id) { + id + email + name + } + } +` + +export const Loading = () =>
Loading...
+ +export const Empty = () =>
EmptyUser not found
+ +export const Failure = ({ + error, +}: CellFailureProps) => ( +
{error?.message}
+) + +export const Success = ({ + emptyUser, +}: CellSuccessProps) => { + return +} diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx new file mode 100644 index 000000000000..400bbb0cfb07 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx @@ -0,0 +1,82 @@ +import type { EditEmptyUserById, UpdateEmptyUserInput } from 'types/graphql' + +import type { RWGqlError } from '@redwoodjs/forms' +import { + Form, + FormError, + FieldError, + Label, + TextField, + Submit, +} from '@redwoodjs/forms' + +type FormEmptyUser = NonNullable + +interface EmptyUserFormProps { + emptyUser?: EditEmptyUserById['emptyUser'] + onSave: (data: UpdateEmptyUserInput, id?: FormEmptyUser['id']) => void + error: RWGqlError + loading: boolean +} + +const EmptyUserForm = (props: EmptyUserFormProps) => { + const onSubmit = (data: FormEmptyUser) => { + props.onSave(data, props?.emptyUser?.id) + } + + return ( +
+ onSubmit={onSubmit} error={props.error}> + + + + + + + + + + + + + + +
+ + Save + +
+ +
+ ) +} + +export default EmptyUserForm diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx new file mode 100644 index 000000000000..f4a1f120301f --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx @@ -0,0 +1,98 @@ +import type { + DeleteEmptyUserMutation, + DeleteEmptyUserMutationVariables, + FindEmptyUsers, +} from 'types/graphql' + +import { Link, routes } from '@redwoodjs/router' +import { useMutation } from '@redwoodjs/web' +import type { TypedDocumentNode } from '@redwoodjs/web' +import { toast } from '@redwoodjs/web/toast' + +import { QUERY } from 'src/components/EmptyUser/EmptyUsersCell' +import { truncate } from 'src/lib/formatters' + +const DELETE_EMPTY_USER_MUTATION: TypedDocumentNode< + DeleteEmptyUserMutation, + DeleteEmptyUserMutationVariables +> = gql` + mutation DeleteEmptyUserMutation($id: Int!) { + deleteEmptyUser(id: $id) { + id + } + } +` + +const EmptyUsersList = ({ emptyUsers }: FindEmptyUsers) => { + const [deleteEmptyUser] = useMutation(DELETE_EMPTY_USER_MUTATION, { + onCompleted: () => { + toast.success('EmptyUser deleted') + }, + onError: (error) => { + toast.error(error.message) + }, + // This refetches the query on the list page. Read more about other ways to + // update the cache over here: + // https://www.apollographql.com/docs/react/data/mutations/#making-all-other-cache-updates + refetchQueries: [{ query: QUERY }], + awaitRefetchQueries: true, + }) + + const onDeleteClick = (id: DeleteEmptyUserMutationVariables['id']) => { + if (confirm('Are you sure you want to delete emptyUser ' + id + '?')) { + deleteEmptyUser({ variables: { id } }) + } + } + + return ( +
+ + + + + + + + + + + {emptyUsers.map((emptyUser) => ( + + + + + + + ))} + +
IdEmailName 
{truncate(emptyUser.id)}{truncate(emptyUser.email)}{truncate(emptyUser.name)} + +
+
+ ) +} + +export default EmptyUsersList diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx new file mode 100644 index 000000000000..d0adba58b523 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx @@ -0,0 +1,48 @@ +'use client' + +import type { FindEmptyUsers, FindEmptyUsersVariables } from 'types/graphql' + +import { Link, routes } from '@redwoodjs/router' +import type { + CellSuccessProps, + CellFailureProps, + TypedDocumentNode, +} from '@redwoodjs/web' + +import EmptyUsers from 'src/components/EmptyUser/EmptyUsers' + +export const QUERY: TypedDocumentNode< + FindEmptyUsers, + FindEmptyUsersVariables +> = gql` + query FindEmptyUsers { + emptyUsers { + id + email + name + } + } +` + +export const Loading = () =>
Loading...
+ +export const Empty = () => { + return ( +
+ {'No emptyUsers yet. '} + + {'Create one?'} + +
+ ) +} + +export const Failure = ({ error }: CellFailureProps) => ( +
{error?.message}
+) + +export const Success = ({ + emptyUsers, +}: CellSuccessProps) => { + return +} diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx new file mode 100644 index 000000000000..50b6532b5b07 --- /dev/null +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx @@ -0,0 +1,57 @@ +'use client' + +import type { + CreateEmptyUserMutation, + CreateEmptyUserInput, + CreateEmptyUserMutationVariables, +} from 'types/graphql' + +import { navigate, routes } from '@redwoodjs/router' +import { useMutation } from '@redwoodjs/web' +import type { TypedDocumentNode } from '@redwoodjs/web' +import { toast } from '@redwoodjs/web/toast' + +import EmptyUserForm from 'src/components/EmptyUser/EmptyUserForm' + +const CREATE_EMPTY_USER_MUTATION: TypedDocumentNode< + CreateEmptyUserMutation, + CreateEmptyUserMutationVariables +> = gql` + mutation CreateEmptyUserMutation($input: CreateEmptyUserInput!) { + createEmptyUser(input: $input) { + id + } + } +` + +const NewEmptyUser = () => { + const [createEmptyUser, { loading, error }] = useMutation( + CREATE_EMPTY_USER_MUTATION, + { + onCompleted: () => { + toast.success('EmptyUser created') + navigate(routes.emptyUsers()) + }, + onError: (error) => { + toast.error(error.message) + }, + } + ) + + const onSave = (input: CreateEmptyUserInput) => { + createEmptyUser({ variables: { input } }) + } + + return ( +
+
+

New EmptyUser

+
+
+ +
+
+ ) +} + +export default NewEmptyUser diff --git a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/UserExample/UserExample/UserExample.tsx b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/UserExample/UserExample/UserExample.tsx index 063e50e4248f..291e659d8a31 100644 --- a/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/UserExample/UserExample/UserExample.tsx +++ b/__fixtures__/test-project-rsc-external-packages-and-cells/web/src/components/UserExample/UserExample/UserExample.tsx @@ -1,3 +1,5 @@ +'use client' + import { Link, routes, navigate } from '@redwoodjs/router' import { useMutation } from '@redwoodjs/web' import { toast } from '@redwoodjs/web/toast' @@ -65,7 +67,8 @@ const UserExample = ({ userExample }: Props) => {