⚠️ This release has breaking changes. Please see the "Breaking" section for more info.
v0.37 Highlights 🎉
🚀 GraphQL levels (way) up: Envelop+Helix
This release marks the official debut of @redwoodjs/graphql-server
. It's been a long time coming and we're overjoyed to finally share it with you as Redwood's premiere GraphQL server. You can expect can expect built-in performance, security, authentication by default, and directives. (And, oh my, you are going to ❤️ directives.)
From its conception and all throughout its development we collaborated closely with The Guild. It's an understatement to say that we couldn't have done it without them. Infinite thanks go out to members like @dotan, @n1ru4l and @ardatan who have been with us every step of the way, tirelessly answering our questions and helping us make @redwoodjs/graphql-server
what it is today.
To recap on why we're so excited about this new package, see Using GraphQL Envelop+Helix in Redwood.
🎛️ Generator Templates
Say goodbye to having to tweak every generator just the way you want after you run it. In v0.37, you can customize all of Redwood's generator templates to your heart's content! Just setup the templates, make all the the edits you want there, once, and generate away. It even works for scaffolds!
🎉 New Splash Page
Redwood's splash page got a makeover! Next time you start the dev server on a new Redwood project, you'll be greeted with a new-look splash page that's packed with resource cards, social links, all of your app's routes, and, if you're devving at night, it even has dark mode.
Huge thanks to @alicelovescake and @margalit; they spent weeks on this one from start to finish and went above and beyond responding to every piece of feedback we had. You guys rock!
🤖 Codemods
Want the latest Redwood has to offer without the hassle of upgrading? Starting with v0.37, we'll be releasing as many codemods as we can with every Redwood release to make upgrading easier. Because of Redwood's opinionated architecture, most codemods even find the files they have to modify themselves!
Changelog
Unique contributors: 18
PRs merged: 73
Added
- Custom Generators #3384 by @cannikin 🎉
- Re-vamp Redwood splash-page #3183 by @alicelovescake @margalit 🎉
- Add @redwoodjs/codemods #3411 by @jtoar @dac09 🎉
- dbAuth: Adds custom error messages to login and signup #3253 by @cannikin
- Add router tests for special characters in path and query #3236 by @zackdotcomputer
- Support extra options in scenario to be passed to Prisma create #3261 by @callingmedic911
- Add watchNodeModules option to yarn rw dev #3282 by @jtoar
- Support email link authentication with Firebase #3347 by @doesnotexist
- Feat: Config for Prisma slow query threshold #3379 by @callingmedic911
- Adds descriptions to @requireAuth @skipAuth directives and its generator templates #3435 by @dthyresson
Changed
- Sunset Apollo Server and make GraphQL Helix and Envelop default graphql handler #3286 by @dthyresson @dac09 🎉
- Refactors graphql-server to use dedicated plug-in directory and tests #3307 by @dthyresson @dac09 🎉
- Update the pre-production warning to an almost-ready notice #3388 by @mojombo
- Handle matching trailing slash #2628 by @KrisCoulson
- Remove showUI to reduce friction fixes issue:2361 #2629 by @shahbaz17
- Replace url and file loaders with asset modules #3293 by @jtoar
- Use newer plugin syntax for babel-plugin-inline-react-svg #3333 by @jtoar
- Surface errors on the api side #3353 by @Tobbe
- dependency upgrades; graphql-tools bug fix, typescript 4.4, deprecated babel-eslint, clean up core/package.json #3371 by @thedavidprice
- Import from specific files, not internal #3373 by @jtoar
- Use and extend react-hook-form's
valueAs
coercion #3376 by @jtoar - Build @redwoodjs/forms types #3387 by @jtoar
- Refactor type generator parse method #3381 by @dac09
- Improvements to rw exec scripts #3382 by @dac09
- Use data previously created in the scenario as input to other scenario data #3386 by @KrisCoulson
- extend scenario with support for scenario.only #3385 by @KrisCoulson
- Only set dbAuth session cookie as
Secure
in non-development environment #3392 by @cannikin - rw lint - return exit code #3450 by @cjreimer
- Rework decoders to better handle custom provider #3414 by @dthyresson
- Updates auth related imports for graphql-server #3408 by @dthyresson
- Better handle and log authentication and context-related exceptions within the GraphQL lifecycle #3409 by @dthyresson
- removed lng: 'en' from i18n template #3465 by @realStandal
Fixed
- Scaffold: Fix page props type #3262 by @callingmedic911
- Fix routes with . (DOT) on Webpack dev server #3294 by @callingmedic911
- Fix: Run tests inside
/src
dir only #3303 by @callingmedic911 - fix(testing): Fix mockCurrentUser on api side #3369 by @dac09
- Fix: Generate types when generating sdl #3378 by @callingmedic911
- Fix gitpod port forwarding #3434 by @dac09
- Fix: Log error during GraphQL execution #3380 by @callingmedic911
- Fix gql validation and gql schema gen on windows #3397 by @dac09
- fix(gql-server): Allow query/mutate without directives #3398 by @dac09
- Remove invalid config from babel-inline-react-svg plugin #3403 by @dac09
- Fix add-directives codemod #3461 by @jtoar
- Fix invalid type in DbAuthHandler #3420 by @HarunKilic
- fix generated service template (remove beforeResolvers) #3421 by @thedavidprice
- Make sure import filename case matches actual filename #3426 by @cannikin
- Fixes GraphQL Verification to check for directives on queries #3428 by @dthyresson
- Fixes Type error with requireAuth roles in lib/auth template #3431 by @dthyresson
- Fix: TS error on Cell prop without Query variable #3415 by @callingmedic911
- adding missing dep for Netlify #3462 by @thedavidprice
- Add missing dependency graphql-tag to graphql-server #3495 by @jtoar
Chore
- Router README: Document new navigation functionality #3267 by @Tobbe
- Router README: Document new navigation functionality #3267 by @Tobbe
- Update env variable for gitpod rwfw #3306 by @dac09
- Bump tmpl from 1.0.4 to 1.0.5 #3406 by @dependabot
- Document trailingSlashes prop on the router #3460 by @KrisCoulson
- Readme updates to introduction technologies for GraphQL #3433 by @dthyresson
Breaking ⚠️
1. Apollo GraphQL Server removed and replaced with Helix + Envelop; Required GraphQL Directives; beforeResolver
deprecation
With this release comes a high performance, secure-by-default GraphQL Server via a new @redwoodjs/graphql-server
package. Additionally, all SDL Queries and Mutations now must have a directive or both yarn rw dev
and yarn rw build
will fail. (Note: Apollo GraphQL Client is still used for the Web side and has not been changed.)
Directives are the new default for Secure Services, so beforeResolver
will be fully deprecated in release v0.38
.
Follow the code modification instructions in the "How to Upgrade" section below.
2. Recommended change for Custom Auth provider implementations
In prior releases, the custom
auth decoder (or any unknown decoders) simply passed along the token
as the decoded
value to your application's getCurrentUser
.
This behavior has changed. (See this file change in PR #3414)
Now the custom
decoder never returns a decoded token or value. Instead, when authenticating a request, it is the developer's responsibility to use other values from getCurrentUser
, e.g. token
or header parameters.
tl;dr:
You must now use the token
or other parameters (like headers) to authenticate. A custom decoder behaves the same way.
3. Router: paths will now match /about
and /about/
by default
There is a new trailingSlashes prop added to the Router . Under the hood trailingSlashes has a default value of 'never'. Which means /about
and /about/
will now match. (Previously this would be two separate routes.) You will no longer be sent to the PageNotFound component if you have an extra slash. (See #2628)
If you need the trailingSlashes to represent two separate routes you can use trailingSlashes="preserve"
:
4. Tests now must be inside respective web/ and api/ src/
directories
If your tests are located outside of src/
, they will no longer be included when Jest (via yarn rw test
) is run. This would be an uncommon situation. (See #3303)
5. Auth Magic.link upgraded to SKD v5
Breaking change regarding "Custom session duration", which may affect custom implementations. See Changelog and "custom session duration" PR magiclabs/magic-js#199
6. Typescript upgraded to v4.4
Do pay particular attention to type changes to catch()
. We found internally that catch(error)
required catch(error: any)
.
7. Deprecated custom Redwood Form coercion transformValue.
Redwood Form's transformValue
prop on field components is deprecated in favor of React-hook-form's valueAs
coercion (introduced in v6.12). (see PR#3376)
Follow the code modification instructions in the "How to Upgrade" section below.
8. dbAuth adds custom error message to login and signup
This release refactors the options object given to DbAuthHandler to bundle up related login and signup options together. (See #3253)
Follow the code modification instructions in the "How to Upgrade" section below.
9. Firebase Auth upgraded to v9
Firebase has been upgrade to support email link authentication. There are many related breaking changes and required code modifications. Do look through PR #3347 for more details.
And follow the code modification instructions in the "How to Upgrade" section below.
How to Upgrade
Code Modifications
✨ New Automated Codemods
Many of the upgrade steps below can be completed using the new @redwoodjs/codemods
package. Amazing! You'll run the codemods using the npm
subcommand npx
, which allows you to run a package without needing to install either locally or globally. Here's an example codemod you'll run from your project root directory:
🚀 Codemod Available
npx @redwoodjs/codemods update-graphql-function
Here are the only other things you should know in order to get the most out of this preview feature:
- Start by saving the current state of your project with git — there should be no uncommitted changes. This way, if you ever need to re-try or rollback a codemod step, you can easily revert using git.
- Always review the file changes after you run a codemod. They're going to be accurate 90% of the time. The remaining 10% is on you.
- Heads up 👷 Codemods currently work with npm v6, which is included with Node.js v14. (
npx
is a subcommand of thenpm
command.) If you encounter errors, you are likely using npm v7 (Node.js v16). Confirm either way by runningnpm --version
. (Need to switch versions? Try nvm for Mac or Windows.)
Helpful Typescript Commands
These tips only apply after you have upgraded to the latest release.You might notice type errors that don't seem right or up-to-date. Try:
yarn rw g types
and then- from the VS Code command pallete run "Developer: Reload Window"
If you see Prisma type errors, you might need to re-generate the Prisma client:
yarn rw prisma generate
🧭 Follow the v0.37 Upgrade Guide
The SuperOfficial™ upgrade guide will walk you through everything required to get up and running on v0.37. We've posted it here on the Redwood Forums — be sure to ask questions as needed and let us know how it goes:
Here's a list of the upgrade steps included:
- Change imports and graphql.js handler function
- Enable Secure Services
- Update your Scenarios
- Update Forms
- Consider Modifying getCurrentUser
- If you use Firebase Auth
- If you use dbAuth
Once you're done, don't forget to upgrade your packages!
Upgrade Packages to v0.36.x from v0.37.x
Run the following command within your App's directory:
yarn redwood upgrade
Upgrading from an earlier version?
Please follow the "how to upgrade" sections for each newer version here 👉 https://github.com/redwoodjs/redwood/releases, as there may be manual code mods needed for each version.
Upgrading to a version that is not the latest?
The command yarn rw upgrade
will always upgrade to the latest (i.e. most recent) Redwood version. If you need to upgrade incrementally to an earlier, specific release, use the --tag
option. For example, if you need to upgrade from v0.27.0 to v0.28.4, run the following command:
yarn redwood upgrade --tag 0.28.4
Need help or having trouble upgrading packages?
See this forum topic for manual upgrade instructions and general upgrade help.