Having trouble with a mutation that updates two it...
# prisma-whats-new
d
Having trouble with a mutation that updates two items at once (they have a many-to-many) relationship. This is the available mutation:
Copy code
addToCourseInSession(
  coursesCourseId: ID!, 
  sessionsSessionId: ID!)
  : AddToCourseInSessionPayload
So this is the mutation I am try to use in the playground:
Copy code
mutation {
	addToCourseInSession(
    coursesCourseId: cj30rdvha7w5n0119cifmh8y7, 
    sessionsSessionId: cj30rfjq71f8d0108ljnkq7ci): 
  AddToCourseInSessionPayload
}
I am getting a basic syntax error so I think I am just missing something small
p
@doug_w I think you are missing the quotes around the IDs?
d
Thx. I tried that. It is specifically complaining about the
:
on line 4
p
Oh, you are not selecting any valid fields! Try: mutation { addToCourseInSession( coursesCourseId: "cj30rdvha7w5n0119cifmh8y7", sessionsSessionId: "cj30rfjq71f8d0108ljnkq7ci") { }
then use autocomplete after the {
d
Is this what you mean by autocomplete?
p
yes
d
( see gen)
p
In GraphQL, you cannot select a whole Object. You need to define every field that you want the server to return
mutation { addToCourseInSession(coursesCourseId: "cj30rdvha7w5n0119cifmh8y7", sessionsSessionId: "cj30rfjq71f8d0108ljnkq7ci") { coursesCourse { id } } }
d
Oh nice that works and totally makes sense. I now understand what they were showing me in the first place with the generated mutation. Thanks! 👏
p
You are welcome 🙂
n
awesome, glad you guys figured out it 🙌
nice to see you in Slack now, too @pso 👋