github blitz-js/blitz v0.24.0

latest releases: blitz@2.0.0-alpha.26, @blitzjs/rpc@2.0.0-alpha.26, @blitzjs/next@2.0.0-alpha.26...
19 months ago

💥 Breaking Changes

  • Rename ssrQuery to invokeWithMiddleware: #1218

🔥 Major Changes

  • 🔥 Add useMutation()
    • This replaces the old method of calling mutations directly
    • Read the docs
  • 🔥 Add ability to strongly type ctx: #1160
    • This requires switching to either useMutation() or invoke() for your mutations.
    • Read the docs
  • 🔥 Add ability to strongly type PublicData: #1219

1. Add this new file to your app:

// types.ts
import { DefaultCtx, SessionContext, DefaultPublicData } from "blitz"
import { User } from "db"

declare module "blitz" {
  export interface Ctx extends DefaultCtx {
    session: SessionContext
  }
  export interface PublicData extends DefaultPublicData {
    userId: User["id"]
  }
}

2. And now you can make this change in queries/mutations:

-import {SessionContext} from "blitz"
+import {Ctx} from "blitz"

-export default async function login(input: LoginInputType, ctx: {session?: SessionContext} = {}) {
+export default async function login(input: LoginInputType, ctx: Ctx) {

🚀 Minor Changes

  • Add invoke() — the new way to imperatively call queries/mutations: #1217
  • Add invalidateQuery() utility: #1226
  • Add getQueryKey() utility: #1224
  • Lots of logging & error improvements!! Remove result logs, redact passwords, etc: #1212
  • Change all generated file paths to be kebab-case: #1197
  • Make ctx.session.authorize() function as a type guard: #1222
  • Add blitz db seed for seeding data in your database: #678 #1239

🐞 Patches

  • Fix session race condition that would result in CSRF errors or users being logged out: #1209
  • Speed up blitz start by 40% by adding incremental dev cache: #1137
  • Fix blitz console not closing on first Ctrl+D: #1142
  • Fix ES5 compatibility: upgrade superjson to 1.2.2: #1147
  • Fix bug in dev where files were not being removed correctly when deleted: #1161
  • Fix useQuery's mutate and router.push in same frame will cause error: #1176
  • Reduce re-renders by memoizing useParams and useRouterQuery: #1157
  • Don't run prettier is blitz new fails: #1202
  • Improve error message when attempting useQuery with regular functions: #1223
  • Enforce NodeJS Version >= 12 for CLI: #1213
  • Fix isBlitzRoot() for blank deps/devDeps: #1242
  • Fix: pass undefined through the RPC layer: #1156
  • Upgrade react-query to 2.23.0: #945
  • Upgrade superjson to 1.2.3: #1230

⚡️ Changes to the New App Template

  • Improve Form typing: remove need to pass schema type: #1144
  • Fix tests not working out of the box: #1165
  • Fix docs link on default homepage: #1250
  • Add 'restart server' to instruction to index page: #1140

👩‍🍳 Recipes

  • Fix DocumentContext import in Material UI recipe: #1253

Internal Meta Changes

  • Back out no-for-of eslint rule: df46939
  • Docs: add drmas as a contributor: #1146
  • Docs: add jorisre as a contributor: #1158
  • Docs: add brunocrosier as a contributor: #1159
  • Big refactor of internal types for react-query, RPC, and resolvers: #1172
  • Add .node-version: #1148
  • Docs: add lukebennett as a contributor: #1180
  • Adds tests for core parsePublicDataToken: #1184
  • Docs: add clgeoio as a contributor: #1190
  • Docs: add ntgussoni as a contributor: #1189
  • Docs: add hmajid2301 as a contributor: #1227
  • Refactor and add tests for public data store: #1204
  • Docs: add phillippschmedt as a contributor: #1228
  • Docs: add hasparus as a contributor: #1235
  • Upgrade monorepo typescript from 3.8 to 4.0: #1236
  • Upgrade prisma version in examples apps: #1238
  • Fix middleware test for win and mac: #1245
  • Docs: add mizchi as a contributor: #1252
  • Docs: add konradkalemba as a contributor: #1255
  • Changed @blitzjs/core to only export public API: #1246
  • Docs: add Alucard17 as a contributor: #1256
  • Add tests for add-dependency-executor: #1259
  • Docs: add Dohxis as a contributor: #1261
  • Promote Simon to L2 Maintainership: #1264
  • Add @kitze as a contributor: 7fac013
  • Redirect MAINTAINERS.md to the new page in the docs: f83ce0b
  • Add @Kamshak as a contributor: c439679
  • Update @brunocrosier as a contributor: 6a37f32
  • Update @engelkes-finstreet as a contributor: 1335379
  • Update @engelkes-finstreet as a contributor: 5ebed4b
  • Add @sandulat as a contributor: 406b643

Credits

Huge thanks to @Zeko369, @brunocrosier, @sandulat, @ryardley, @drmas, @johncantrell97, @hmajid2301, @jamiedavenport, @phillippschmedt, @Weilbyte, @mizchi, @nitaking, @jorisre, @lukebennett, @wKovacs64, @hardfire, @konradkalemba, @clgeoio, @Alucard17, @Dohxis, and @Skn0tt for helping!

Don't miss a new blitz release

NewReleases is sending notifications on new releases.