- I still db modelling confusing but prisma is helping a lot, this is the syntax i need to remember:
model Link {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
description String
url String
postedBy User? @relation(fields: [postedById], references: [id])
postedById Int?
}
model User {
id Int @id @default(autoincrement())
name String
email String @unique
password String
links Link[]
}
Link
has a relation to User
. Link
uses the postedById
feild to reference an item in the User
table via its id
feild in the User
table.
These are touch points when adding a new table and graphql api endpoint
- update the
prisma.schema
- run
npx prisma migrate dev
to update the prisma db - run
npx prisma generate
to update the prisma client libs - update the
schema.graphql
file to include any new mutation definitions.- Add the signature of any new types.
- Update any existing types which may rely on the new type
- implement any new mutation resolvers
- Implement any new type resolvers
- Update any existing type resolvers which depend on the new type resolver
- remember to export new mutation and resolvers and include in the
ApolloServer
instance