Connect in upsert on subfield inside update{Entitiy} is not working for me

prisma

#1

Hello,

when doing the following:

mutation {
  updateSpace(
    where:{
    	id:"cjfg8go3h00150959jtnxr76g"
    },
    data:{
      rooms:{
        upsert:{
          where:{
            pusherRoomId: "1235"
          }
          update:{
         		pusherRoomId: "1235"
            name:"ageagaeea"
            userIds:{
               connect: [
                {
                  id: "cjfg8go44001a0959m56dqu4u"
                },
                {
                  id: "cjfg8gob7002d0959lslbrg6z"
                }
            ]
            }
          }
          create:{
            pusherRoomId: "1235"
            name:"ageagaeea"
            userIds:{
               connect: [
                {
                  id: "cjfg8go44001a0959m56dqu4u"
                },
                {
                  id: "cjfg8gob7002d0959lslbrg6z"
                }
            ]
            }
          }
        }
      }
    }
  ) {
    id
    rooms {
      pusherRoomId
      userIds {
        id
        firstName
      }
    }
  }
}

The connect on userIds is not working. It does not connect the userIds.

I have ended up creating the room separately with the connected userIds, and then connecting said room the the resource. However, shouldn’t the above have worked?

Thanks for any insight.


#2

Hey @harrisrobin :wave:

Would you mind sharing your data model so I can get a better overview of the situation you are trying to solve? I would also love to hear what you are trying to achieve with the above query, as we might be able to resolve it differently.


#3

I ended up solving it differently myself.

We can close this.

Here is the relevant data model if you are curious:

type Space {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  name: String
  size: PLACE_SIZES
  shortDescription: String
  description: String
  business: Business
  slug: String
  maxGuests: Int
  maxSeats: Int
  reviews: [Review!]!
  squareFeet: Float
  roomsAvailable: Int @default(value: 1)
  amenities: Amenities
  activities: [Activity!]!
  style: Styles
  host: User!
  pricing: Pricing
  location: Location
  views: Views
  guestRequirements: GuestRequirements
  policies: Policies
  houseRules: HouseRules
  pictures: [Picture!]!
  popularity: Int
  numRatings: Int
  avgRating: Int
  rooms: [Room!]!
}


type Room {
  name: String
  createdAt: DateTime!
  updatedAt: DateTime!
  isPrivate: Boolean
  pusherRoomId: Int! @unique
  createdByUserId: String
  users: [User!]!
  space: Space
  booking: Booking
}


type User {
  id: ID! @unique
  auth0id: String! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  userType: USER_TYPE!
  firstName: String
  lastName: String
  email: String! @unique
  picture: Picture
  locale: String
  gender: String
  identity: String
  verified: Boolean! @default(value: "false")
  password: String
  phone: String
  responseRate: Float
  responseTime: Int
  ownedSpaces: [Space!]!
  location: Location
}

#4

Great, thanks! :slightly_smiling_face: