0.14.0 (2024-07-17)
🎉 New Features
-
Simplified Auth User API: Introduced a simpler API for accessing user auth fields (for example
username
,email
,isEmailVerified
) directly on theuser
object, eliminating the need for helper functions. -
Improved the API for calling Operations (Queries and Actions) directly on both the client and the server.
-
Improved API for calling Operations (Queries and Actions) directly.
-
Auth Hooks: you can now hook into the auth process with
onBeforeSignup
,onAfterSignup
hooks. You can also modify the OAuth redirect URL withonBeforeOAuthRedirect
hook.app myApp { ... auth: { onBeforeSignup: import { onBeforeSignup } from "...", onAfterSignup: import { onAfterSignup } from "...", onBeforeOAuthRedirect: import { onBeforeOAuthRedirect } from "...", }, }
-
Auth: you can now use Discord as a social auth provider (by @wardbox)
-
Using the Prisma Schema file directly: define your database schema in the
schema.prisma
file and Wasp will use it to generate the database schema and Prisma client code. -
Added the
wasp db reset
command for resetting the database.
⚠️ Breaking Changes & Migration Guide
New tsconfig.json
file
Wasp 0.14.0 requires some changes to your tsconfig.json
file.
Visit the migration guide for details.
Strict options when building the wasp
package
The wasp
package is now built with strictBindCallApply
, alwaysStrict
, noImplicitThis
, and strictFunctionTypes
.
This is a breaking change only if you have manually set your tsconfig.json
's strict
field to false
and are relying on it being more permissive.
To fix the errors, enable the options listed above and make sure your code type checks.
This quirk is only temporary. You'll soon be able to use any tsconfig.json
options you want.
Track this issue for progress: #1827
Directly calling Queries on the client
You can now call Queries directly from the client without dealing with
queryCacheKey
s. Wasp takes care of it under the hood:
Now:
const doneTasks = await getTasks({ isDone: true });
Before:
const doneTasks = await getTasks(getTasks.queryCacheKey, { isDone: true });
Accessing AuthUser
data
We had to make a couple of breaking changes to reach the new simpler Auth API:
-
You don't need to use
getUsername
to access the username:- Before: Used
getUsername
to access the username. - After: Directly use
user.identities.username?.id
.
- Before: Used
-
You don't need to use
getEmail
to access the email:- Before: Used
getEmail
to access the email. - After: Directly use
user.identities.email?.id
.
- Before: Used
-
Better API for accessing
providerData
:- Before: Required complex logic to access typed provider data.
- After: Directly use
user.identities.<provider>.<value>
for typed access.
-
Better API for accessing
getFirstProviderUserId
:- Before: Used
getFirstProviderUserId(user)
to get the ID. - After: Use
user.getFirstProviderUserId()
directly on the user object.
- Before: Used
-
You don't need to use
findUserIdentity
any more:- Before: Relied on
findUserIdentity
to check which user identity exists. - After: Directly check
user.identities.<provider>
existence.
- Before: Relied on
These changes improve code readability and lower the complexity of accessing user's auth fields. Follow the detailed migration steps to update your project to 0.14.0.
Using the Prisma Schema file
Wasp now uses the schema.prisma
file to generate the database schema and Prisma client code. This means that you should move your database schema from the main.wasp
file to the schema.prisma
file.
This means that this entity in main.wasp
:
entity Task {=psl
id Int @id @default(autoincrement())
description String
isDone Boolean
userId Int
user User @relation(fields: [userId], references: [id])
psl=}
will move to the schema.prisma
file:
model Task {
id Int @id @default(autoincrement())
description String
isDone Boolean
userId Int
user User @relation(fields: [userId], references: [id])
}
Read more about the migration steps in the migration guide.
Note on Auth Helper Functions (getUsername
, getEmail
etc.)
These changes only apply to getting auth fields from the user
object you receive from Wasp, for example in the authRequired
enabled pages or context.user
on the server. If you are fetching the user and auth fields with your own queries, you can keep using most of the helpers. Read more about using the auth helpers.
🐞 Bug fixes
- Updated the
tsconfig.json
to make sure IDEs don't underlineimport.meta.env
when users use client env vars. - Fixed
netlify.toml
to include the correct build path for the client app. - Fixed the client router to ensure that user defined routes don't override Wasp defined routes by moving the user defined routes to the end of the route list.
- Fixed the CRUD client helpers to accept the same params as the
useQuery
anduseAction
hooks.
🔧 Small improvements
- Improved the default loading spinner while waiting for the user to be fetched.
- Hided Prisma update message to avoid confusion since users shouldn't update Prisma by themselves.
- When an unknown OAuth error happens, Wasp now logs the error on the server to help with debugging.
- Improved default gitignore to more tightly target dotenv files and to allow for example dotenv files and .env.client.
- Improved the type signature of client auth helpers (e.g.
getEmail
) to make them accept the minimal required user object. - Improved the documentation and added extra TypeScript content.
- Improved RPC type inference.