Hi everyone!! another newbie playing with Prisma/G...
# orm-help
l
Hi everyone!! another newbie playing with Prisma/GraphQL... 😅 I'm struggling with one thing... it doesn't have to be that difficult... I'm missing something Basically I have my model Video
Copy code
type Video {
  id: ID! @unique
  title: String!
  tags: [Tag!]!
}
with the mutation:
Copy code
createVideo(
    title: String!, 
    tagsIds: [ID!],
  ): Video!
and this is what I have right now in the resolver... I've tried several things
Copy code
createVideo: (root, args, context, info) => {
      return context.db.mutation.createVideo({
        data: {
          title: args.title, 
          tags: {
            connect: {
              id: args.tagsIds
            }
          },
        },
      }, info)
    },
  },
This is what I'm sending, the two IDs I'm sending are tags that exist on database:
Copy code
mutation {
  createVideo(
    title: "Neehar Venugopal - A Beginner's Guide to Code Splitting Your React App - React Conf 2017"
    tagsIds: ["cjoopece2000a0899n8jsjkr4", "cjoo9e0eq004d0824nibmtzl2"],
  ) {
    id
  }
}
probably missing something basic... but I haven't found much information about how to send a group of IDs related to another table any help will be appreciated 🙂 and this is the error I'm getting, by the way...
Expected type ID at value.id; ID cannot represent value: ["cjoopece2000a0899n8jsjkr4", "cjoo9e0eq004d0824nibmtzl2"]
n
Hey Lobo 👋 you're looking for an API feature that unfortunately doesn't exist in the Prisma API at the moment, here is the feature request for it: https://github.com/prisma/prisma/issues/2036
I just answered a Stackoverflow question yesterday for someone who had the same problem: https://stackoverflow.com/questions/53237538/overide-entire-relation-field-with-prisma/53393097#53393097
l
oh! thanks for your answer Nikolas! I see...
🙌 1
would it be a way to work around this limitation?
n
Yes, you need to pass all IDs individually:
Copy code
prisma.createVideo({
   title: "Neehar Venugopal - A Beginner's Guide to Code Splitting Your React App - React Conf 2017",
    tags: {
      connect: [{
        id: "cjoopece2000a0899n8jsjkr4",
        id: "cjoo9e0eq004d0824nibmtzl2"
      }]
    }
})
l
in the resolver?
n
Yes 🙂
l
but the id's will be dynamic
well... it's javascript, I can build the object of ids before passing it to the connect []
n
Yes, you need to map the IDs in
args.tagsIds
to the structure that I showed in the code snippet 🙂
l
thanks for your help 🙂
🙌 1
appreciate