Extensions
This page will provide an explanation on how to use extensions exported by Project Toolchain. These extensions are automatically generated by Prisma Util at schema generation time.
To use extensions generated by Prisma Util, you just have to import them like this:
The [FEATURE_NAME]
section is replaced by the name of the feature that you want to import.
The list of available imports is dynamic and based on what features you've enabled in your configuration file. All features that make use of Project Toolchain's Extension API will display a notice on their page and the name of their exports.
For standardization purposes, all features making use of Project Toolchain's Extension API will follow these naming conventions to ensure a smoother developer experience:
[FEATURE_NAME]
will always be lowercase and spaces will be replaced with hyphens.Based on the number of extensions, the feature will export:
If there is only one extensions for this feature, it will be the default export for
prisma-util/toolchain/extensions/[FEATURE_NAME]/index.js
.If there are more than two extensions for this feature, they will be exported individually and the default export for this file will be an ExportedExtensionsBase object.
Types & Definitions
ExportedExtensionsBase
This type represents an object with the following TypeScript definition:
The key of this object will be the extension name (this is set by each feature that makes use of Project Toolchain's Extensions API and documented on the specific page of said feature) and the value will be a function. This function takes your PrismaClient as a parameter, so it can initialize all the values required and will return an extension that you can use in PrismaClient's $extends
function.
This type also has a function (add
) that will add all of the extensions for this feature to your PrismaClient and return the provided instance of this client.
Last updated