Skip to content

Commit

Permalink
Merge branch 'main' into tobbe-rsc-rsa-extract-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Sep 19, 2024
2 parents e5d5303 + a67d5fb commit 24be544
Show file tree
Hide file tree
Showing 52 changed files with 334 additions and 116 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)
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
2 changes: 1 addition & 1 deletion __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"postcss": "^8.4.47",
"postcss-loader": "^8.1.1",
"prettier-plugin-tailwindcss": "^0.5.12",
"tailwindcss": "^3.4.11"
"tailwindcss": "^3.4.12"
}
}
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
16 changes: 15 additions & 1 deletion docs/versioned_docs/version-8.0/background-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,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 @@ -727,6 +727,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
16 changes: 15 additions & 1 deletion docs/versioned_docs/version-8.1/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
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"jwks-rsa": "3.1.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@types/jsonwebtoken": "9.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"jwks-rsa": "3.1.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@types/aws-lambda": "8.10.145",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/clerk/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@clerk/clerk-sdk-node": "4.13.21"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@types/aws-lambda": "8.10.145",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/clerk/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/custom/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"uuid": "10.0.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@simplewebauthn/server": "7.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@redwoodjs/web": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@redwoodjs/graphql-server": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"firebase-admin": "12.5.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@types/aws-lambda": "8.10.145",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/netlify/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"jsonwebtoken": "9.0.2"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@types/aws-lambda": "8.10.145",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/netlify/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"jsonwebtoken": "9.0.2"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/aws-lambda": "8.10.145",
"@types/jsonwebtoken": "9.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@supabase/ssr": "0.5.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/auth": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supertokens/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"jwks-rsa": "3.1.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/api": "workspace:*",
"@redwoodjs/framework-tools": "workspace:*",
"@types/jsonwebtoken": "9.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supertokens/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"react": "19.0.0-rc-f2df5694-20240916"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "14.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"prepublishOnly": "NODE_ENV=production yarn build"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"@redwoodjs/framework-tools": "workspace:*",
"concurrently": "8.2.2",
"publint": "0.2.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/framework-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build:types": "tsc --build --verbose"
},
"dependencies": {
"@arethetypeswrong/cli": "0.16.2",
"@arethetypeswrong/cli": "0.16.4",
"esbuild": "0.23.1",
"fast-glob": "3.3.2",
"fs-extra": "11.2.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/graphql-server/src/createGraphQLYoga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const createGraphQLYoga = ({
realtime,
trustedDocuments,
openTelemetryOptions,
includeScalars,
}: GraphQLYogaOptions) => {
let schema: GraphQLSchema
let redwoodDirectivePlugins = [] as Plugin[]
Expand Down Expand Up @@ -85,6 +86,7 @@ export const createGraphQLYoga = ({
directives: projectDirectives,
subscriptions: projectSubscriptions,
schemaOptions,
includeScalars,
})
} catch (e) {
logger.fatal(e as Error, '\n ⚠️ GraphQL server crashed \n')
Expand Down
12 changes: 11 additions & 1 deletion packages/graphql-server/src/makeMergedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {
ServicesGlobImports,
GraphQLTypeWithFields,
SdlGlobImports,
RedwoodScalarConfig,
} from './types'

const wrapWithOpenTelemetry = async (
Expand Down Expand Up @@ -358,11 +359,13 @@ export const makeMergedSchema = ({
schemaOptions = {},
directives,
subscriptions = [],
includeScalars,
}: {
sdls: SdlGlobImports
services: ServicesGlobImports
directives: RedwoodDirective[]
subscriptions: RedwoodSubscription[]
includeScalars?: RedwoodScalarConfig

/**
* A list of options passed to [makeExecutableSchema](https://www.graphql-tools.com/docs/generate-schema/#makeexecutableschemaoptions).
Expand All @@ -371,9 +374,16 @@ export const makeMergedSchema = ({
}) => {
const sdlSchemas = Object.values(sdls).map(({ schema }) => schema)

const rootEntries = [rootGqlSchema.schema]

// We cannot access the getConfig from project-config here so the user must supply it via a config option
if (includeScalars?.File !== false) {
rootEntries.push(rootGqlSchema.scalarSchemas.File)
}

const typeDefs = mergeTypes(
[
rootGqlSchema.schema,
...rootEntries,
...directives.map((directive) => directive.schema), // pick out schemas from directives
...subscriptions.map((subscription) => subscription.schema), // pick out schemas from subscriptions
...sdlSchemas, // pick out the schemas from sdls
Expand Down
Loading

0 comments on commit 24be544

Please sign in to comment.