Skip to content

Commit

Permalink
Merge branch 'main' into navigate-scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
guitheengineer committed Sep 20, 2024
2 parents 53821b3 + d2fe56c commit 1d74cab
Show file tree
Hide file tree
Showing 131 changed files with 1,015 additions and 736 deletions.
5 changes: 5 additions & 0 deletions .changesets/11540.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- fix(graphql): Allow including 'File' scalar by default to be disabled (#11540) by @Josh-Walker-GM

As of v8.0.0 a `File` scalar was added to your graphql schema by default. This could be problematic if you wanted to define your own `File` scalar.

With this change it is now possible to disable including this scalar by default. To see how to do so look at the `Default Scalar` section of the `Graphql` docs [here](https://docs.redwoodjs.com/docs/graphql#default-scalars)
5 changes: 5 additions & 0 deletions .changesets/11542.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- feat(cli): Make scaffolded layout routing type-safe (#11542) by @Tobbe

With this feature we now make sure only valid route names are passed as `titleTo` and `buttonTo` props to the scaffolded layout.

This also means you get helpful code completion when typing out the prop values
3 changes: 3 additions & 0 deletions .changesets/11572.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Default NODE_ENV to "development" if it's `undefined` when starting jobs worker (#11572) by @cannikin

This mimics the behavior of `yarn rw dev` where `NODE_ENV` will equal `development` if you don't set it explicitly.
1 change: 1 addition & 0 deletions .changesets/11578.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixes `yarn rw jobs clear` command (#11578) by @cannikin
3 changes: 3 additions & 0 deletions .changesets/11591.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- fix(router): Add missing dependency for RSC (#11591) by @Tobbe

Adding missing dependency `react-server-dom-webpack` to the `@redwoodjs/router` package. This should fix an error some people were seeing when trying to use RSC.
5 changes: 4 additions & 1 deletion __fixtures__/fragment-test-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
"prisma": {
"seed": "yarn rw exec seed"
},
"packageManager": "yarn@4.1.1"
"packageManager": "yarn@4.1.1",
"resolutions": {
"rollup": "4.21.3"
}
}
4 changes: 2 additions & 2 deletions __fixtures__/fragment-test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@redwoodjs/router": "7.0.0",
"@redwoodjs/web": "7.0.0",
"humanize-string": "2.1.0",
"react": "19.0.0-rc-8269d55d-20240802",
"react-dom": "19.0.0-rc-8269d55d-20240802"
"react": "19.0.0-rc-f2df5694-20240916",
"react-dom": "19.0.0-rc-f2df5694-20240916"
},
"devDependencies": {
"@redwoodjs/vite": "7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/rsc-caching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"packageManager": "yarn@4.1.1",
"resolutions": {
"@apollo/client-react-streaming/superjson": "^1.12.2",
"react-is": "19.0.0-rc-8269d55d-20240802"
"react-is": "19.0.0-rc-f2df5694-20240916"
}
}
4 changes: 2 additions & 2 deletions __fixtures__/rsc-caching/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@redwoodjs/web": "8.0.0-canary.1102",
"@tobbe.dev/rsc-test": "0.0.5",
"client-only": "0.0.1",
"react": "19.0.0-rc-8269d55d-20240802",
"react-dom": "19.0.0-rc-8269d55d-20240802"
"react": "19.0.0-rc-f2df5694-20240916",
"react-dom": "19.0.0-rc-f2df5694-20240916"
},
"devDependencies": {
"@redwoodjs/vite": "8.0.0-canary.1102",
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/test-project-rsa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"packageManager": "yarn@4.1.1",
"resolutions": {
"@apollo/client-react-streaming/superjson": "^1.12.2",
"react-is": "19.0.0-rc-8269d55d-20240802"
"react-is": "19.0.0-rc-f2df5694-20240916"
}
}
4 changes: 2 additions & 2 deletions __fixtures__/test-project-rsa/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@redwoodjs/forms": "8.0.0-canary.144",
"@redwoodjs/router": "8.0.0-canary.144",
"@redwoodjs/web": "8.0.0-canary.144",
"react": "19.0.0-rc-8269d55d-20240802",
"react-dom": "19.0.0-rc-8269d55d-20240802"
"react": "19.0.0-rc-f2df5694-20240916",
"react-dom": "19.0.0-rc-f2df5694-20240916"
},
"devDependencies": {
"@redwoodjs/vite": "8.0.0-canary.144",
Expand Down
3 changes: 2 additions & 1 deletion __fixtures__/test-project-rsc-kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"packageManager": "yarn@4.1.1",
"resolutions": {
"@apollo/client-react-streaming/superjson": "^1.12.2",
"react-is": "19.0.0-rc-8269d55d-20240802"
"react-is": "19.0.0-rc-f2df5694-20240916",
"rollup": "4.21.3"
}
}
4 changes: 2 additions & 2 deletions __fixtures__/test-project-rsc-kitchen-sink/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@redwoodjs/web": "8.0.0-canary.861",
"@tobbe.dev/rsc-test": "0.0.5",
"client-only": "0.0.1",
"react": "19.0.0-rc-8269d55d-20240802",
"react-dom": "19.0.0-rc-8269d55d-20240802"
"react": "19.0.0-rc-f2df5694-20240916",
"react-dom": "19.0.0-rc-f2df5694-20240916"
},
"devDependencies": {
"@redwoodjs/vite": "8.0.0-canary.861",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@
& > main {
display: flex;
flex-grow: 1;

& > div {
width: 100%;
}
}
}
3 changes: 2 additions & 1 deletion __fixtures__/test-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"packageManager": "yarn@4.4.0",
"resolutions": {
"@storybook/react-dom-shim@npm:7.6.17": "https://verdaccio.tobbe.dev/@storybook/react-dom-shim/-/react-dom-shim-8.0.8.tgz",
"react-is": "19.0.0-rc-8269d55d-20240802"
"react-is": "19.0.0-rc-f2df5694-20240916",
"rollup": "4.21.3"
}
}
8 changes: 4 additions & 4 deletions __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
"@redwoodjs/router": "8.0.0",
"@redwoodjs/web": "8.0.0",
"humanize-string": "2.1.0",
"react": "19.0.0-rc-8269d55d-20240802",
"react-dom": "19.0.0-rc-8269d55d-20240802"
"react": "19.0.0-rc-f2df5694-20240916",
"react-dom": "19.0.0-rc-f2df5694-20240916"
},
"devDependencies": {
"@redwoodjs/vite": "8.0.0",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.45",
"postcss": "^8.4.47",
"postcss-loader": "^8.1.1",
"prettier-plugin-tailwindcss": "^0.5.12",
"tailwindcss": "^3.4.11"
"tailwindcss": "^3.4.12"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const Loading = () => <div>Loading...</div>
export const Empty = () => {
return (
<div className="rw-text-center">
{'No contacts yet. '}
No contacts yet.{' '}
<Link to={routes.newContact()} className="rw-link">
{'Create one?'}
Create one?
</Link>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const Loading = () => <div>Loading...</div>
export const Empty = () => {
return (
<div className="rw-text-center">
{'No posts yet. '}
No posts yet.{' '}
<Link to={routes.newPost()} className="rw-link">
{'Create one?'}
Create one?
</Link>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Toaster } from '@redwoodjs/web/toast'

type LayoutProps = {
title: string
titleTo: string
titleTo: keyof typeof routes
buttonLabel: string
buttonTo: string
buttonTo: keyof typeof routes
children: React.ReactNode
}

Expand Down
16 changes: 15 additions & 1 deletion docs/docs/background-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ By checking the `lastError` field in the database you can see what the last erro
## Deployment
For many use cases you may simply be able to rely on the job runner to start your job workers, which will run forever:
For many use cases you may be able to rely on the job runner to start and detach your job workers, which will then run forever:
```bash
yarn rw jobs start
Expand All @@ -723,6 +723,20 @@ Of course if you have a process monitor system watching your workers you'll want
:::
### NODE_ENV
You'll need to explicitly set your `NODE_ENV` when in environments other than development or test. We like having a `.env` file in a serverfull production environment, and you just include:
```bash
NODE_ENV=production
```
If you're using Docker, make sure you have an `ENV` declaration for it:
```docker
ENV NODE_ENV="production"
```
## Advanced Job Workers
As noted above, although the workers are started and detached using the `yarn rw jobs start` command, there is nothing to monitor those workers to make sure they keep running. To do that, you'll want to start the workers yourself (or have your process monitor start them) using command line flags.
Expand Down
37 changes: 37 additions & 0 deletions docs/docs/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,43 @@ api | - deletePost Mutation
To fix these errors, simple declare with `@requireAuth` to enforce authentication or `@skipAuth` to keep the operation public on each as appropriate for your app's permissions needs.
## Default Scalars
Redwood includes a selection of scalar types by default.
Currently we allow you to control whether or not the `File` scalar is included automatically or not. By default we include the `File` scalar which maps to the standard `File` type. To disable this scalar you should add config to two places:
1. In your `redwood.toml` file like so:
```toml
[graphql]
includeScalars.File = false
```
2. In your `functions/graphql.ts` like so:
```typescript
export const handler = createGraphQLHandler({
authDecoder,
getCurrentUser,
loggerConfig: { logger, options: {} },
directives,
sdls,
services,
onException: () => {
// Disconnect from your database with an unhandled exception.
db.$disconnect()
},
// highlight-start
includeScalars: {
File: false,
},
// highlight-end
})
```
With those two config values added your schema will no longer contain the `File` scalar by default and you are free to add your own or continue without one.
## Custom Scalars
GraphQL scalar types give data meaning and validate that their values makes sense. Out of the box, GraphQL comes with `Int`, `Float`, `String`, `Boolean` and `ID`. While those can cover a wide variety of use cases, you may need more specific scalar types to better describe and validate your application's data.
Expand Down
56 changes: 24 additions & 32 deletions docs/docs/how-to/dbauth-passwordless.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,41 +57,33 @@ yarn rw g service users
Now that you have the file, let's add the `generateToken` function.
```javascript {21} title="/api/src/services/users/users.js"
// add this import to the top of the file
import CryptoJS from 'crypto-js'
```javascript title="/api/src/services/users/users.js"
// add the following two imports to the top of the file
import crypto from 'node:crypto'
import { hashPassword } from '@redwoodjs/auth-dbauth-api'

// add this to the bottom of the file
export const generateLoginToken = async ({ email }) => {
try {
// look up if the user exists
let lookupUser = await db.user.findFirst({ where: { email } })
const lookupUser = await db.user.findFirst({ where: { email } })

if (!lookupUser) {
return { message: 'Login Request received' }
}

// here we're going to generate a random password of 6 numbers
// here we're going to generate a random password of 6 numbers
let randomNumber = (() => {
let random = CryptoJS.lib.WordArray.random(6)
let randomString = random.toString()
let sixDigitNumber = randomString.replace(/\D/g, '')
if (sixDigitNumber.length < 6) {
sixDigitNumber = sixDigitNumber.padStart(6, '0')
}
if (sixDigitNumber.length > 6) {
sixDigitNumber = sixDigitNumber.slice(0, 6)
}
return sixDigitNumber.toString()
})()
const randomNumber = crypto
.randomInt(0, 1_000_000)
.toString()
.padStart(6, '0')
console.log({ randomNumber }) // email the user this number
let salt = CryptoJS.lib.WordArray.random(30)
let loginToken = CryptoJS.PBKDF2(randomNumber, salt, {
keySize: 256 / 32,
}).toString()

const [loginToken, salt] = hashPassword(randomNumber)
// now we'll update the user with the new salt and loginToken
let loginTokenExpiresAt = new Date()
const loginTokenExpiresAt = new Date()
loginTokenExpiresAt.setMinutes(loginTokenExpiresAt.getMinutes() + 15)
let data = {
const data = {
salt,
loginToken,
loginTokenExpiresAt,
Expand All @@ -113,7 +105,7 @@ export const generateLoginToken = async ({ email }) => {
In addition to the new function, we need to add it to the sdl file. While we're here let's also ensure we do not expose the loginToken. This file may be users.sdl.js or users.sdl.ts depending on if you set up Redwood to use JavaScript or TypeScript.
```javascript {21} title="/api/src/graphql/users.sdl.js"
```javascript title="/api/src/graphql/users.sdl.js"
export const schema = gql`
type User {
id: Int!
Expand Down Expand Up @@ -226,7 +218,7 @@ import {
FieldError,
} from '@redwoodjs/forms'
import { navigate, routes, Link } from '@redwoodjs/router'
import { MetaTags, useMutation } from '@redwoodjs/web'
import { Metadata, useMutation } from '@redwoodjs/web'
import { Toaster, toast } from '@redwoodjs/web/toast'
const GENERATE_LOGIN_TOKEN = gql`
mutation generateLoginToken($email: String!) {
Expand Down Expand Up @@ -259,7 +251,7 @@ const LoginPasswordlessForm = ({ setWaitingForCode, setEmail }) => {

return (
<>
<MetaTags title="Login" />
<Metadata title="Login" />
<main className="rw-main">
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
<div className="rw-scaffold rw-login-container">
Expand Down Expand Up @@ -339,7 +331,7 @@ import {
FieldError,
} from '@redwoodjs/forms'
import { navigate, routes, Link } from '@redwoodjs/router'
import { MetaTags, useMutation } from '@redwoodjs/web'
import { Metadata, useMutation } from '@redwoodjs/web'
import { Toaster, toast } from '@redwoodjs/web/toast'

import { useAuth } from 'src/auth'
Expand All @@ -366,7 +358,7 @@ const LoginPasswordlessTokenForm = ({ setWaitingForCode, email, code }) => {

return (
<>
<MetaTags title="Login" />
<Metadata title="Login" />
<main className="rw-main">
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
<div className="rw-scaffold rw-login-container">
Expand Down Expand Up @@ -460,7 +452,7 @@ yarn rw g page LoginPasswordless
import { useEffect, useState } from 'react'

import { useLocation } from '@redwoodjs/router'
import { MetaTags } from '@redwoodjs/web'
import { Metadata } from '@redwoodjs/web'

import LoginPasswordlessForm from 'src/components/LoginPasswordlessForm/LoginPasswordlessForm'
import LoginPasswordlessTokenForm from 'src/components/LoginPasswordlessTokenForm/LoginPasswordlessTokenForm'
Expand Down Expand Up @@ -488,7 +480,7 @@ const LoginPasswordlessPage = () => {

return (
<>
<MetaTags
<Metadata
title="LoginPasswordless"
description="LoginPasswordless page"
/>
Expand Down Expand Up @@ -530,7 +522,7 @@ import {
Submit,
} from '@redwoodjs/forms'
import { Link, navigate, routes } from '@redwoodjs/router'
import { MetaTags } from '@redwoodjs/web'
import { Metadata } from '@redwoodjs/web'
import { toast, Toaster } from '@redwoodjs/web/toast'

import { useAuth } from 'src/auth'
Expand Down Expand Up @@ -577,7 +569,7 @@ const SignupPage = () => {

return (
<>
<MetaTags title="Signup" />
<Metadata title="Signup" />

<main className="rw-main">
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
Expand Down
Loading

0 comments on commit 1d74cab

Please sign in to comment.