Returning full complement of data from mutation


#1

Hi all, hope someone can help me.

Firstly when using the info object in my mutations am I right it only returns the information defined in the schema for that Mutation. For example if I have defined a mutation createEvent:

createEvent(title: String!, description: String, startDate: DateTime!, locations: [Locations]): Event!

Am I right in saying once I run the actual mutation:

 async createEvent(parent, args, ctx, info) {
    const { title, description, locations, startDate } = args;
    const { userId } = ctx.request;

    const newEvent = await ctx.db.mutation.createEvent(
      {
        data: {
          title,
          description,
          locations: { create: [...locations] },
          startDate,
          leader: {
            connect: {
              id: userId,
            },
          },
        },
      },
      info
    );
  
    return newEvent;

Then newEvent will only contain the id, description startDate and Locations array?

I want to return everything defined in my Event datamodel as I will be using it in a subscription:

type Event {
id: ID! @unique @id
leader: User! @relation(name: “UserEvents”)
title: String!
description: String
startDate: DateTime!
attendees: [User] @relation(name: “AttendingEvents”)
locations: [Location] @relation(name: “EventLocations”)
comments: [Comment]
updatedAt: DateTime! @updatedAt
createdAt: DateTime! @createdAt
}

What is the best practice for doing this?

Thanks

Ross