Update Prisma API
Goals
On this page, you will learn how to:
- Change the data model of your Prisma service
- Deploy the adjusted data model to update your Prisma API
- Send nested queries and mutations
Adjust your data model
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 }Copy
(Re-)Deploy your Prisma service
To apply the changes you just made to your data model, you need to (re-)deploy your Prisma service:
prisma deployCopy
Explore the Prisma API in a Playground
Open a GraphQL Playground using the following command:
prisma playgroundCopy
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.
Create post & user
Query users & posts
mutation { createPost( data: { title: "GraphQL is great", author: { create: { name: "Bob" } } } ) { id published author { id } } }Copy
Fantastic! 🎉 You are now able to make changes to your Prisma API. Learn how to consume the API using Prisma bindings next.
Next Step