maoosi/prisma-appsync

Issue: Foreign keys not included in upsert model

micklaw opened this issue · 2 comments

Hey folks,

Im upgrading from the beta to rc and havng an issue. You can see in the schema.prisma output below that a field 'venueTypeid' exists on the model for Venue.

This used to come in to the upsert model, but now does not, is this expected behaviour, if so how should I handle this change?

Schema

/// @gql(subscriptions: null)
/// @auth(mutations: [{ allow: userPools, groups: ["Admin", "Official", "TeamStaff", "AssociationStaff"] }])
model Venue {
  id          String         @unique @default(dbgenerated("public.uuid_generate_v4()")) @db.Uuid
  name        String
  shortName   String?        @map("short_name")
  venueTypeId String         @map("venue_type_id") @db.Uuid
  teams       Team[]
  fixtures    TeamFixture[]
  venueType   VenueType      @relation(fields: [venueTypeId], references: [id], onDelete: NoAction, onUpdate: NoAction)
  sponsors    VenueSponsor[]

  @@unique([name, venueTypeId], map: "venue_unique_key")
  @@map("venue")
}

Outputs

type Venue
    @aws_iam
    @aws_cognito_user_pools(
        cognito_groups: [
            "Admin"
            "AssociationStaff"
            "Official"
            "TeamStaff"
            "ReadOnly"
        ]
    ) {
    id: String!
    name: String!
    shortName: String
    venueTypeId: String!
    teams: [Team]
    fixtures: [TeamFixture]
    venueType: VenueType!
    sponsors: [VenueSponsor]
}

Input model

input VenueUpdateInput {
    id: String
    name: String
    shortName: String
    teams: VenueTeamsUpdateRelationsInput
    fixtures: VenueFixturesUpdateRelationsInput
    venueType: VenueVenueTypeUpdateRelationsInput
    sponsors: VenueSponsorsUpdateRelationsInput
}

Any help would be appeciated on how to handle mutations in the new world given the relationship column is now missing for 'venueTypeId'

After a bi of digging, I think this may have do it?

mutation UpsertVenue($shortName: String = "test...", $name: String = "test...", $venueTypeId: String = "83e38...", $id: String = "8223...") {
  upsertVenue(	
    where: { id: $id }, 
    data: { id: $id, 
      venueType: { 
        connect: { id: $venueTypeId } 
      }, 
      name: $name, 
      shortName: $shortName 
    }) {
    id
    name
    shortName
    venueTypeId
  }
}

Is this as designed?

Clsoing as this works for my use case