15 November, 2023
These changes have been released with version 0.372
of the CLI.
Improvements to Function Hooks
We’ve made some improvements and bug fixes to the way function hooks work and also updated the docs page, but here is a summary of the changes:
- All hooks are now typed so they can be async / return Promises
beforeQuery
in anupdate
function can now return a query builderbeforeWrite
in anupdate
function now receives the current record as a fourth argumentbeforeWrite
is now called fordelete
functions- Both
beforeWrite
andafterWrite
fordelete
functions are passed the record that is being deleted as the third argument, rather than just the id
Using non-model inputs
Another thing that is now fully supported is using non-model inputs in functions. An example of this would be something like:
model Film {
fields {
title Text
releaseDate Date?
}
actions {
list searchFilms(title, unreleased: Boolean?) @function
}
}
In this schema the searchThings
action accepts title
which is a model field and unreleased
which is not a model field and is explicitly typed as an optional boolean. The default query that is generated for this function will handle the title
input automatically but will do nothing with the unreleased
input - that is for you to handle in your function. For example:
export default SearchThings({
beforeQuery(ctx, inputs, query) {
if (inputs.unreleased) {
return query.where({
releaseDate: {
equals: null,
},
})
}
return query;
}
});
Non-model inputs can use any basic type - Text
, Boolean
, Number
, Date
, and Timestamp
as well as enums.
3rd-party Authentication
We have been working on providing really good support for integrating your Keel app with third-party authentication providers, such as Google, Facebook and the likes. Not only that, but we are working on providing a better (and more secure) auth experience using access tokens, refresh tokens, and a set of dedicated OAuth2 endpoints. Do watch this space over the next 2 weeks! 👀
OIDC Token Authentication (pre-release)
Today we have shipped a pre-release of OIDC Token authentication. With this flow, you can authenticate your users from any OpenID Connect provider using just an ID token. This feature is not yet publicly available, nor have we published documentation for it, but if you would like to get started early then please do raise your hand on our Discord channel. We'll happily work with you on getting integrated.
Fixes and Improvements
We've also released a bunch of fixes and improvements (opens in a new tab) to our CLI, the SDK packages, and to our VS Code extension.
For any issues or feedback, please visit the support channel on our community discord (opens in a new tab) or contact us at help@keel.so.
Thank you for using Keel!