hey guys, I'm having some trouble with implanting ...
# orm-help
k
hey guys, I'm having some trouble with implanting resolves for many-to-many relation for instance say we have two types: type Post { id: ID! @unique tags: [Tag!]! } type Tag { id: ID! @unique posts: [Post!]! } now how can i write a mutation function for adding a new Post ? if i try to add a list of tags to the post in query it will complaining about not having any post. The framework i previously worked with (django) had a method for this situation (add) but now i cant find any possible solution here please help.
u
Copy code
mutation {
  createPost(data: { Tag: { create: { text: "qwe" } } }) {
    id
  }
}
And use Playground for create queries, not a django, Luke 🙂
k
yup tnx 😄 i found this approach accidentally when i was reading this part of doc: https://www.prisma.io/docs/understand-prisma/prisma-vs-traditional-orms/prisma-vs-sequelize-c4fk/#transactions i think there should be a better documentation to explain all these approaches or maybe i wasn't able to find any if you know a good reference please inform me. tnx alot 👍
u
One of main advantages of GraphQL - auto api documentation, so you can see all api docs in Playground or other gql clients. Prisma client 1:1 copy of gql api in playground