docs/1.27/prisma-graphql-api/reference/raw-database-access-qwe4.mdx
export const meta = { title: "Raw Database Access", position: 70, }
You can access the native API of the underlying database and perform custom operations directly against it.
All example subscriptions on this page are based on a Prisma service configured with this datamodel:
type User {
id: ID! @unique
name: String!
createdAt: DateTime!
updatedAt: DateTime!
}
To enable raw database access, add rawAccess to your docker-compose.yml file.
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.27
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: postgres
host: postgres
port: 5432
# port: 3306
user: prisma
password: prisma
migrations: true
rawAccess: true
postgres:
image: postgres:10.3
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres: ~
To create a new User through the native API, you can use the executeRaw mutation.
mutation {
executeRaw(query: "INSERT INTO default$default.\"User\" (Id, Name, \"updatedAt\",\"createdAt\") VALUES ('cjnkpvm0b000d0b22j7csr04v', 'Abhi', '2018-10-22T19:54:47.606Z', '2018-10-22T19:54:47.606Z');")
}
To find all Users
mutation {
executeRaw(query: "SELECT * FROM default$default.\"User\"")
}