This plugin requires a little more setup than other plugins because it integrates with the prisma to
generate some types that help the plugin better understand your prisma schema. Previous versions of
this plugin used to infer all required types from the prisma client itself, but this resulted in a
poor dev experience because the complex types slowed down editors, and some more advanced use cases
could not be typed correctly.
Now the types Pothos uses will be generated whenever you re-generate your prisma client. Run the
following command to re-generate the client and create the new types:
additional options:
clientOutput: Where the generated code will import the PrismaClient from. The default is the
full path of wherever the client is generated. If you are checking in the generated file, using
@prisma/client is a good option.
It is strongly recommended NOT to put your prisma client into Context. This will result in slower
type-checking and a laggy developer experience in VSCode. See
this issue for more details.
You can also load or create the prisma client dynamically for each request. This can be used to
periodically re-create clients or create read-only clients for certain types of users.
When prisma is built for edge run-times like cloudflare workers, the prisma client no-longer exposes
the dmmf datamodel Pothos uses when building the schema. To work around this, you can have the
pothos generator generate the datamodel instead:
When using the generateDatamodel option, the prisma client will add a getDatamodel function in
the generated output. When using this option, you should be using a .ts file rather than a .d.ts
file for the output.
When setting up the builder, you can now use the getDatamodel function: