How to return a string after performing a mutation



I have this mutation I want to return a success message once it is executed:

async attending (parent, { id }, ctx, info) {
    const userId = getUserId(ctx)

    const eventExists = await ctx.db.exists.Event({

    if (!eventExists) {
      throw new Error('Sorry, event not found!')

    await ctx.db.mutation.updateEvent(
        where: {
        data: {
          participants: {
            connect: {
              id: userId

    return `You're attending this event!`

And mutation is defined as:

type Mutation {
  attending(id: ID!): String!

But I keep getting this error:

"Field \"updateEvent\" of type \"Event\" must have a selection of subfields. Did you mean \"updateEvent { ... }\"?",


The error message is unrelated to your attending resolver. Looks like your updateEvent resolver is causing the issue.


The problem is that your query looks like this:

mutation {
  attending(id: "abc")

You are passing the info object into updateEvent, but they are not “compatible”.

Remove the info object that you pass into updateEvent to fix this.


Ignore my answer and see Nilan’s response. He’s right :roll_eyes: