docs/1.15/get-started/02-update-prisma-api-c001.mdx
import QueryChooser from 'components/Markdown/QueryChooser'
export const meta = { title: 'Update Prisma API', position: 2, nextText: 'Fantastic! 🎉 You are now able to make changes to your Prisma API. Learn how to consume the API using Prisma bindings next.' }
On this page, you will learn how to:
Update the data model in datamodel.graphql as follows. You are adding a new Post type to the data model as well as a relation between User and Post (via the posts and author fields):
type User {
id: ID! @unique
name: String!
posts: [Post!]!
}
type Post {
id: ID! @unique
title: String!
published: Boolean! @default(value: "false")
author: User
}
To apply the changes you just made to your data model, you need to (re-)deploy your Prisma service:
prisma deploy
Open a GraphQL Playground using the following command:
prisma playground
Because of the relation that was added to the data model, you can now send nested queries and mutations to read and modify connected nodes.
<QueryChooser titles={["Create post & user","Query users & posts"]}>
mutation {
createPost(data: {
title: "GraphQL is great"
author: {
create: {
name: "Bob"
}
}
}) {
id
published
author {
id
}
}
}
query {
users {
id
name
posts {
id
title
published
}
}
}