Skip to content

Commit c3a2ebb

Browse files
committed
Merge branch 'main' of github.com:redwoodjs/redwood into feat/dbauth-fetch-handler
* 'main' of github.com:redwoodjs/redwood: Add missing cli-helpers test file (redwoodjs#9833) Add cli-helpers util to update redwood.toml (redwoodjs#9832) Tweak graphiql setup messages (redwoodjs#9831) exp setup sentry: Fix file extension (redwoodjs#9829) Fastify config: Use exact file extension in log message (redwoodjs#9828) Remove unused Fastify plugin (redwoodjs#9827) Add trusted-documents to fragments CI smoke-test (redwoodjs#9826) prerender: Enable Trusted Documents support (redwoodjs#9825) trustedDocuments.test.ts: Format source cli: add missing dep jscodeshift (redwoodjs#9823) graphql setup fragments: Move telemetry to main handler (redwoodjs#9819) feat: Adds Setup CLI Command to Configure GraphQL Trusted Documents (redwoodjs#9800) Update cli tsconfig to reference used packages (redwoodjs#9822) fragments setup: newline fix + refactor->rename (redwoodjs#9821) yarn rw setup graphql fragments (redwoodjs#9811)
2 parents be84ace + d9892f4 commit c3a2ebb

File tree

78 files changed

+3994
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3994
-70
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = {
2727
'packages/babel-config/src/__tests__/__fixtures__/**/*',
2828
'packages/core/**/__fixtures__/**/*',
2929
'packages/codemods/**/__testfixtures__/**/*',
30+
'packages/cli/**/__testfixtures__/**/*',
3031
'packages/core/config/storybook/**/*',
3132
'packages/studio/dist-*/**/*',
3233
],

.github/workflows/ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,18 @@ jobs:
779779
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
780780
REDWOOD_DISABLE_TELEMETRY: 1
781781

782+
- name: Enable trusted-documents in Fragments test project
783+
run: npx -y tsx ./tasks/test-project/set-up-trusted-documents ${{ steps.set-up-test-project.outputs.test-project-path }}
784+
env:
785+
REDWOOD_DISABLE_TELEMETRY: 1
786+
787+
- name: 📄 Run prerender smoke tests against Fragments test project (with trusted-documents enabled)
788+
working-directory: tasks/smoke-tests/prerender
789+
run: npx playwright test
790+
env:
791+
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-test-project.outputs.test-project-path }}
792+
REDWOOD_DISABLE_TELEMETRY: 1
793+
782794
fragments-smoke-tests-skip:
783795
needs: detect-changes
784796

docs/docs/cli-commands.md

+66-1
Original file line numberDiff line numberDiff line change
@@ -1999,11 +1999,76 @@ We perform a simple compatibility check in an attempt to make you aware of poten
19991999
20002000
It's the author of the npm package's responsibility to specify the correct compatibility range, so **you should always research the packages you use with this command**. Especially since they will be executing code on your machine!
20012001
2002+
### setup graphql
2003+
2004+
This command creates the necessary files to support GraphQL features like fragments and trusted documents.
2005+
2006+
#### Usage
2007+
2008+
Run `yarn rw setup graphql <feature>`
2009+
2010+
#### setup graphql fragments
2011+
2012+
This command creates the necessary configuration to start using [GraphQL Fragments](./graphql/fragments.md).
2013+
2014+
```
2015+
yarn redwood setup graphql fragments
2016+
```
2017+
2018+
| Arguments & Options | Description |
2019+
| :------------------ | :--------------------------------------- |
2020+
| `--force, -f` | Overwrite existing files and skip checks |
2021+
2022+
#### Usage
2023+
2024+
Run `yarn rw setup graphql fragments`
2025+
2026+
#### Example
2027+
2028+
```bash
2029+
~/redwood-app$ yarn rw setup graphql fragments
2030+
✔ Update Redwood Project Configuration to enable GraphQL Fragments
2031+
✔ Generate possibleTypes.ts
2032+
✔ Import possibleTypes in App.tsx
2033+
✔ Add possibleTypes to the GraphQL cache config
2034+
```
2035+
2036+
#### setup graphql trusted-documents
2037+
2038+
This command creates the necessary configuration to start using [GraphQL Trusted Documents](./graphql/trusted-documents.md).
2039+
2040+
2041+
```
2042+
yarn redwood setup graphql trusted-documents
2043+
```
2044+
2045+
#### Usage
2046+
2047+
Run `yarn rw setup graphql trusted-documents`
2048+
2049+
#### Example
2050+
2051+
```bash
2052+
~/redwood-app$ yarn rw setup graphql trusted-documents
2053+
✔ Update Redwood Project Configuration to enable GraphQL Trusted Documents ...
2054+
✔ Generating Trusted Documents store ...
2055+
✔ Configuring the GraphQL Handler to use a Trusted Documents store ...
2056+
```
2057+
2058+
2059+
If you have not setup the RedwoodJS server file, it will be setup:
2060+
2061+
```bash
2062+
✔ Adding the experimental server file...
2063+
✔ Adding config to redwood.toml...
2064+
✔ Adding required api packages...
2065+
```
2066+
2067+
20022068
### setup realtime
20032069
20042070
This command creates the necessary files, installs the required packages, and provides examples to setup RedwoodJS Realtime from GraphQL live queries and subscriptions. See the Realtime docs for more information.
20052071
2006-
20072072
```
20082073
yarn redwood setup realtime
20092074
```

docs/docs/graphql/fragments.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ With `registerFragment`, you can register a fragment with the registry and get b
8383

8484
which can then be used to work with the registered fragment.
8585

86+
### Setup
87+
88+
`yarn rw setup graphql fragments`
89+
90+
See more in [cli commands - setup graphql fragments](../cli-commands.md#setup-graphql-fragments).
91+
8692
### registerFragment
8793

8894
To register a fragment, you can simply register it with `registerFragment`.
@@ -200,7 +206,7 @@ the `getCacheKey` is a function where `getCacheKey(42)` would return `Book:42`.
200206
import { registerFragment } from '@redwoodjs/web/apollo'
201207
202208
const { useRegisteredFragment } = registerFragment(
203-
...
209+
// ...
204210
)
205211
```
206212

@@ -281,17 +287,19 @@ To make this easier to maintain, RedwoodJS GraphQL CodeGen automatically generat
281287

282288

283289
```ts
290+
// web/src/App.tsx
291+
284292
import possibleTypes from 'src/graphql/possibleTypes'
285293

286-
...
287-
/// web/src/App.tsx
288-
<RedwoodApolloProvider
289-
graphQLClientConfig={{
290-
cacheConfig: {
291-
...possibleTypes,
292-
},
293-
}}
294-
>
294+
// ...
295+
296+
const graphQLClientConfig = {
297+
cacheConfig: {
298+
...possibleTypes,
299+
},
300+
}
301+
302+
<RedwoodApolloProvider graphQLClientConfig={graphQLClientConfig}>
295303
```
296304

297305
To generate the `src/graphql/possibleTypes` file, enable fragments in `redwood.toml`:

docs/docs/graphql/trusted-documents.md

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ Thus preventing unwanted queries or GraphQl traversal attacks,
9393

9494
## Configure Trusted Documents
9595

96+
Below are instructions to manually configure Trusted Documents in your RedwoodJS project.
97+
98+
Alternatively, you can use the `yarn redwood setup graphql trusted-documents` [CLI setup command](../cli-commands.md#setup-graphql-trusted-docs).
99+
100+
96101
### Configure redwood.toml
97102

98103
Setting `trustedDocuments` to true will

0 commit comments

Comments
 (0)