Skip to content

Commit

Permalink
Add docs for Edge support (#5589)
Browse files Browse the repository at this point in the history
* update deployment guide structure

* add notes for provider specific considerations

* fix typos

* continue cf workers docs

* continue edge support docs

* fix deployment error

* finalized cf worker + pg

* continue edge support docs

* continue edge support docs

* continue edge support docs

* fix internal links

* add note about size limitations

* add redirects

* add preview note

* continue edge support docs

* continue edge support docs

* remove instructions for experiments.asyncWebAssembly from edge deployment docs with Next.js

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx

Co-authored-by: Joël Galeran <[email protected]>

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx

Co-authored-by: Joël Galeran <[email protected]>

* add Turso's driver to edge deployment docs

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* incorporate feedback

* incorporate feedback

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/485-deploy-to-vercel.mdx

* incorporate feedback

* incorporate feedback

* incorporate feedback

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/index.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* incorporate feedback

* incorporate feedback

* incorporate feedback

* incorporate feedback

* add note about wasm env var

* remove netlify and supabase from edge support table

* add note about dotenv-cli

* update vercel's intro sentence

* add note about env vars when using driver adapters

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* Update content/200-orm/200-prisma-client/500-deployment/301-edge/450-deploy-to-cloudflare.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* incorporate feedback

* incorporate feedback

* add unknown word

---------

Co-authored-by: Joël Galeran <[email protected]>
Co-authored-by: Jan Piotrowski <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2024
1 parent 5093593 commit 5c9249a
Show file tree
Hide file tree
Showing 23 changed files with 1,206 additions and 519 deletions.
3 changes: 2 additions & 1 deletion cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"Distroless",
"Nikolas",
"Supavisor",
"inshellisense"
"inshellisense",
"janedoe"
],
"patterns": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ Note that a GraphQL schema can be written code-first or SDL-first. Check out thi
The GraphQL schema and HTTP server are typically handled by separate libraries. Here is an overview of current GraphQL server tools and their purpose:

| Library (npm package) | Purpose | Compatible with Prisma ORM | Prisma integration |
| :-------------------- | :-------------------------- | :--------------------- | :----------------------------------------------------------------------------- |
| `graphql` | GraphQL schema (code-first) | Yes | No |
| `graphql-tools` | GraphQL schema (SDL-first) | Yes | No |
| `type-graphql` | GraphQL schema (code-first) | Yes | [`typegraphql-prisma`](https://www.npmjs.com/package/typegraphql-prisma) |
| `nexus` | GraphQL schema (code-first) | Yes | [`nexus-prisma`](https://graphql-nexus.github.io/nexus-prisma) _Early Preview_ |
| `apollo-server` | HTTP server | Yes | n/a |
| `express-graphql` | HTTP server | Yes | n/a |
| `fastify-gql` | HTTP server | Yes | n/a |
| `graphql-yoga` | HTTP server | Yes | n/a |
| :-------------------- | :-------------------------- | :------------------------- | :----------------------------------------------------------------------------- |
| `graphql` | GraphQL schema (code-first) | Yes | No |
| `graphql-tools` | GraphQL schema (SDL-first) | Yes | No |
| `type-graphql` | GraphQL schema (code-first) | Yes | [`typegraphql-prisma`](https://www.npmjs.com/package/typegraphql-prisma) |
| `nexus` | GraphQL schema (code-first) | Yes | [`nexus-prisma`](https://graphql-nexus.github.io/nexus-prisma) _Early Preview_ |
| `apollo-server` | HTTP server | Yes | n/a |
| `express-graphql` | HTTP server | Yes | n/a |
| `fastify-gql` | HTTP server | Yes | n/a |
| `graphql-yoga` | HTTP server | Yes | n/a |

In addition to these standalone and single-purpose libraries, there are several projects building integrated _application frameworks_:

| Framework | Stack | Built by | Prisma ORM | Description |
| :---------------------------------- | :-------- | :------------------------------------------------ | :--------------------- | :------------------------------------- |
| Framework | Stack | Built by | Prisma ORM | Description |
| :---------------------------------- | :-------- | :------------------------------------------------ | :------------------------- | :------------------------------------- |
| [Redwood.js](https://redwoodjs.com) | Fullstack | [Tom Preston-Werner](https://github.com/mojombo/) | Built on top of Prisma ORM | _Bringing full-stack to the JAMstack._ |

> **Note**: If you notice any GraphQL libraries/frameworks missing from the list, please let us know.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tocDepth: 4

## Default built-in drivers

One of Prisma Client's components is the [Query Engine](/orm/more/under-the-hood/engines) . The Query Engine is responsible for transforming Prisma Client queries to SQL statements. The Query Engine connects to your database using the included drivers that don't require additional setup. The built-in drivers use TCP connections to connect to the database.
One of Prisma Client's components is the [Query Engine](/orm/more/under-the-hood/engines). The Query Engine is responsible for transforming Prisma Client queries to SQL statements. The Query Engine connects to your database via TCP using built-in drivers that don't require additional setup.

![Query flow from the user application to the database with Prisma Client](./images/drivers/qe-query-execution-flow.png)

Expand All @@ -19,7 +19,7 @@ Prisma Client will use the Query Engine to transform the Prisma Client query to

![Query flow from the user application to the database using Prisma Client and driver adapters](./images/drivers/qe-query-engine-adapter.png)

There are 2 different types of driver adapters:
There are two different types of driver adapters:

- [Database driver adapters](#database-driver-adapters)
- [Serverless driver adapters](#serverless-driver-adapters)
Expand All @@ -40,13 +40,13 @@ Prisma ORM maintains the following serverless driver adapters:
- [Neon](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-orm-preview)
- [PlanetScale](/orm/overview/databases/planetscale#how-to-use-the-planetscale-serverless-driver-with-prisma-orm-preview)

## Community maintained database driver adapters
### Community-maintained database driver adapters

You can also build your own driver adapter for the database you're using. The following is a list of community maintained driver adapters:

- [TiDB](https://github.com/tidbcloud/prisma-adapter)

### How to use driver adapters
## How to use driver adapters

To use this feature:

Expand All @@ -71,6 +71,26 @@ To use this feature:
- [PlanetScale](/orm/overview/databases/planetscale#how-to-use-the-planetscale-serverless-driver-with-prisma-orm-preview)
- [Turso](/orm/overview/databases/turso#how-to-connect-and-query-a-turso-database)

## Notes about using driver adapters

### Driver adapters don't read the connection string from the Prisma schema

When using Prisma ORM's built-in drivers, the connection string is read from the `url` field of the `datasource` block in your Prisma schema.
On the other hand, when using a driver adapter, the connection string needs to be provided in your _application code_ when the driver adapter is set up initially. Here is how this is done for the `pg` driver and the `@prisma/adapter-pg` adapter:
```ts highlight=5,normal
import { PrismaClient } from '@prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
import { Pool } from 'pg'
const pool = new Pool({ connectionString: env.DATABASE_URL })
const adapter = new PrismaPg(pool)
const prisma = new PrismaClient({ adapter })
```
See the docs for the driver adapter you're using for concrete setup instructions.

### Driver adapters and custom output paths

Since Prisma 5.9.0, when using the driver adapters Preview feature along with a [custom output path for Prisma Client](/orm/prisma-client/setup-and-configuration/generating-prisma-client#using-a-custom-output-path), you cannot reference Prisma Client using a relative path.
Expand Down
6 changes: 3 additions & 3 deletions content/200-orm/050-overview/500-databases/600-mongodb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@ MongoDB types that are currently unsupported:
When introspecting a MongoDB database, Prisma ORM uses the relevant [scalar types](/orm/prisma-schema/data-model/models#scalar-fields). Some special types also get additional native type annotations:
| MongoDB (Type \| Aliases) | Prisma ORM| Supported | Native database type attribute | Notes |
| ------------------------- | -------- | :-------: | :----------------------------- | :---- |
| `objectId` | `String` | ✔️ | `@db.ObjectId` | |
| MongoDB (Type \| Aliases) | Prisma ORM | Supported | Native database type attribute | Notes |
| ------------------------- | ---------- | :-------: | :----------------------------- | :---- |
| `objectId` | `String` | ✔️ | `@db.ObjectId` | |
[Introspection](/orm/prisma-schema/introspection) adds native database types that are **not yet supported** as [`Unsupported`](/orm/reference/prisma-schema-reference#unsupported) fields:
Expand Down
26 changes: 13 additions & 13 deletions content/200-orm/050-overview/500-databases/840-cockroachdb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,24 @@ The following table lists differences between CockroachDB and PostgreSQL:
The CockroachDB connector maps the [scalar types](/orm/prisma-schema/data-model/models#scalar-fields) from the Prisma ORM [data model](/orm/prisma-schema/data-model/models) to native column types. These native types are mostly the same as for PostgreSQL — see the [Native type mapping from Prisma ORM to CockroachDB](#native-type-mapping-from-prisma-orm-to-cockroachdb) for details. However, there are some limitations:

| CockroachDB (Type \| Aliases) | Prisma ORM | Supported | Native database type attribute | Notes |
| ----------------------------- | --------- | :-------: | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------- |
| `money` | `Decimal` | Not yet | `@db.Money` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41578) |
| `xml` | `String` | Not yet | `@db.Xml` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/43355) |
| `jsonb` arrays | `Json[]` | Not yet | N/A | `Json[]` supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/23468) |
| ----------------------------- | ---------- | :-------: | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------- |
| `money` | `Decimal` | Not yet | `@db.Money` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41578) |
| `xml` | `String` | Not yet | `@db.Xml` | Supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/43355) |
| `jsonb` arrays | `Json[]` | Not yet | N/A | `Json[]` supported in PostgreSQL but [not currently in CockroachDB](https://github.com/cockroachdb/cockroach/issues/23468) |

## Other limitations

The following table lists any other current known limitations of CockroachDB compared to PostgreSQL:

| Issue | Area | Notes |
| ------------------------------------------------------------------------------------------------ | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Primary keys are named `primary` instead of `TABLE_pkey`, the Prisma ORM default. | Introspection | This means that they are introspected as `@id(map: "primary")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70604). |
| Foreign keys are named `fk_COLUMN_ref_TABLE` instead of `TABLE_COLUMN_fkey`, the Prisma ORM default. | Introspection | This means that they are introspected as `@relation([...], map: "fk_COLUMN_ref_TABLE")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70658) |
| Index types `Hash`, `Gist`, `SpGist` or `Brin` are not supported. | Schema | In PostgreSQL, Prisma ORM allows [configuration of indexes](/orm/prisma-schema/data-model/indexes#configuring-the-access-type-of-indexes-with-type-postgresql) to use the different index access method. CockroachDB only currently supports `BTree` and `Gin`. |
| Pushing to `Enum` types not supported | Client | Pushing to `Enum` types (e.g. `data: { enum { push: "A" }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/71388) |
| Searching on `String` fields without a full text index not supported | Client | Searching on `String` fields without a full text index (e.g. `where: { text: { search: "cat & dog", }, },`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/7821) |
| Integer division not supported | Client | Integer division (e.g. `data: { int: { divide: 10, }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41448) |
| Limited filtering on `Json` fields | Client | Currently CockroachDB [only supports](https://github.com/cockroachdb/cockroach/issues/49144) `equals` and `not` filtering on `Json` fields |
| Issue | Area | Notes |
| ---------------------------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Primary keys are named `primary` instead of `TABLE_pkey`, the Prisma ORM default. | Introspection | This means that they are introspected as `@id(map: "primary")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70604). |
| Foreign keys are named `fk_COLUMN_ref_TABLE` instead of `TABLE_COLUMN_fkey`, the Prisma ORM default. | Introspection | This means that they are introspected as `@relation([...], map: "fk_COLUMN_ref_TABLE")`. This will be [fixed in CockroachDB 22.1](https://github.com/cockroachdb/cockroach/pull/70658) |
| Index types `Hash`, `Gist`, `SpGist` or `Brin` are not supported. | Schema | In PostgreSQL, Prisma ORM allows [configuration of indexes](/orm/prisma-schema/data-model/indexes#configuring-the-access-type-of-indexes-with-type-postgresql) to use the different index access method. CockroachDB only currently supports `BTree` and `Gin`. |
| Pushing to `Enum` types not supported | Client | Pushing to `Enum` types (e.g. `data: { enum { push: "A" }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/71388) |
| Searching on `String` fields without a full text index not supported | Client | Searching on `String` fields without a full text index (e.g. `where: { text: { search: "cat & dog", }, },`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/7821) |
| Integer division not supported | Client | Integer division (e.g. `data: { int: { divide: 10, }, }`) is currently [not supported in CockroachDB](https://github.com/cockroachdb/cockroach/issues/41448) |
| Limited filtering on `Json` fields | Client | Currently CockroachDB [only supports](https://github.com/cockroachdb/cockroach/issues/49144) `equals` and `not` filtering on `Json` fields |

## Type mapping between CockroachDB and the Prisma schema

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ model Post {
Since no explicit names are provided via `map` arguments Prisma will assume they follow our default naming convention.

The following table lists the name of each constraint and index in the underlying database:
| Constraint or index | Follows convention | Underlying constraint or index names |
| Constraint or index | Follows convention | Underlying constraint or index names |
| ---------------------------------- | ------------------ | ------------------------------------ |
| `@id` (on `User` > `id` field) | Yes | `User_pk` |
| `@@index` (on `Post`) | Yes | `Post_title_authorName_idx` |
| `@id` (on `Post` > `id` field) | Yes | `Post_pk` |
| `@relation` (on `Post` > `author`) | Yes | `Post_authorName_fkey` |
| `@id` (on `User` > `id` field) | Yes | `User_pk` |
| `@@index` (on `Post`) | Yes | `Post_title_authorName_idx` |
| `@id` (on `Post` > `id` field) | Yes | `Post_pk` |
| `@relation` (on `Post` > `author`) | Yes | `Post_authorName_fkey` |

### Using custom constraint / index names

Expand Down
Loading

0 comments on commit 5c9249a

Please sign in to comment.