Evening all. Wanted to know if there is a way of u...
# orm-help
e
Evening all. Wanted to know if there is a way of updating two Users
follow
and
following
fields in ONE Mutation after one User follows another rather than having to fire off a separate Mutation for each User to update the respective fields like how it is done here https://github.com/prisma/prisma/issues/1609#issuecomment-365266599
Copy code
async follow(parent, { username }, ctx, info) {
    const auth0Id = await parseUserAuth0Id(ctx)
    await ctx.db.mutation.updateUser({
      where: { auth0Id },
      data: {
        following: {
          connect: [{ username }]
        }
      }
    })
    return await ctx.db.mutation.updateUser({
      where: { username },
      data: {
        followers: {
          connect: [{ auth0Id }]
        }
      }
    }, info)
  },

  async unfollow(parent, { username }, ctx, info) {
    const auth0Id = await parseUserAuth0Id(ctx)
    await ctx.db.mutation.updateUser({
      where: { auth0Id },
      data: {
        following: {
          disconnect: [{ username }]
        }
      }
    })
    return await ctx.db.mutation.updateUser({
      where: { username },
      data: {
        followers: {
          disconnect: [{ auth0Id }]
        }
      }
    }, info)
  },