Setup instructions:
git clone https://github.com/prisma/support-challenges
cd support-challenges/challenge-1
# Create local Postgres DB called "test1"
// express-graphql | |
const app = express() | |
app.use('/graphql', graphqlHTTP({ schema })) | |
app.listen(4000, () => { | |
console.log(`Server ready at http://localhost:4000`) | |
}) |
type User { | |
id: ID! | |
name: String | |
} | |
type Query { | |
user(id: ID!): User | |
} |
import { DMMF, DMMFClass, Engine } from './runtime'; | |
/** | |
* Utility Types | |
*/ | |
export declare type Enumerable<T> = T | Array<T>; | |
export declare type MergeTruthyValues<R extends object, S extends object> = { | |
[key in keyof S | keyof R]: key extends false ? never : key extends keyof S ? S[key] extends false ? never : S[key] : key extends keyof R ? R[key] : never; | |
}; | |
export declare type CleanupNever<T> = { | |
[key in keyof T]: T[key] extends never ? never : key; |
I'm using these prisma2
versions:
{
"dependencies": {
"@prisma/photon": "alpha"
},
"devDependencies": {
"prisma2": "alpha",
"ts-node-dev": "^1.0.0-pre.44",
datasource sqlite { | |
url = "file:data.db" | |
provider = "sqlite" | |
} | |
generator photonjs { | |
provider = "photonjs" | |
} | |
model User { |
Addressing feedback from this Gist.
Pagination. Looks like limited to paginate by id. I wanted to paginate by a date field and felt impossible
In the most recent Preview version, (cursor-)pagination can be done by any unique field or combination of fields. For example:
model Post {
id Int @id @default(autoincrement())
title String
Next.js blurs the lines between client and server. It supports pre-rendering pages at build time (SSG) or request time (SSR). Prisma is the perfect companion if you need to work with a database in a Next.js app.
Here is a list of example apps that are based on Next.js and use Prisma on the server to access data from a database:
✍️ Language | 🤖 Server | 🔐 Authentication | 🔗 URL |
---|---|---|---|
TypeScript | API Routes | Yes (via NextAuth.js) | URL |
TypeScript | API Routes | No |
In Prisma 1, it wasn't necessary to specify both sides of a relation, this means this was allowed:
type User {
id: ID! @unique @id
questions: [Question]
}
type Question {
id: ID! @unique @id
grant usage on schema public to supabase_auth_admin; | |
grant all on public."Profile" to supabase_auth_admin; | |
create or replace function create_profile_on_user_creation() returns trigger as | |
$$ | |
begin | |
insert into | |
public."Profile"(id, "modifiedAt") | |
values(new.id, current_timestamp); |