Getting Error when using prisma relations[Solved]

I’m getting a weird error that I can’t resolve, and I’m unsure why it is happening. I tried editing the SDL file multiple times but it just doesn’t recognize authored as a valid field for some reason. I would be happy to answer any further questions. Thank you in advance.

export const schema = gql`
  type Podcast {
    id: Int!
    title: String!
    description: String!
    artwork: String!
    category: String!
    secondaryCategory: String!
    language: String!
    explicit: Boolean!
    author: User!
    authorId: Int!
    episodes: [Episode]!
  }

  type Query {
    podcasts: [Podcast!]! @requireAuth
    podcast(id: Int!): Podcast @requireAuth
  }

  input CreatePodcastInput {
    title: String!
    description: String!
    artwork: String!
    category: String!
    secondaryCategory: String!
    language: String!
    explicit: Boolean!
    authorId: Int!
  }

  input UpdatePodcastInput {
    title: String
    description: String
    artwork: String
    category: String
    secondaryCategory: String
    language: String
    explicit: Boolean
    authorId: Int
  }

  type Mutation {
    createPodcast(input: CreatePodcastInput!): Podcast! @requireAuth
    updatePodcast(id: Int!, input: UpdatePodcastInput!): Podcast! @requireAuth
    deletePodcast(id: Int!): Podcast! @requireAuth
  }
`**strong text**

And my schema

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider      = "prisma-client-js"
  binaryTargets = "native"
}

// Define your own datamodels here and run `yarn redwood prisma migrate dev`
// to create migrations for them and apply to your dev DB.
// TODO: Please remove the following example:
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  hashedPassword      String
  salt                String
  resetToken          String?
  resetTokenExpiresAt DateTime?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  podcasts Podcast[]
  episodes Episode[]
}

model  Podcast {
  id        Int      @id @default(autoincrement())
 title String @unique
 description String
 artwork String
 category String
 secondaryCategory String
 language String
 explicit Boolean
 author   User @relation(fields: [authorId], references: [id])
 authorId Int
 episodes Episode[]
}

model  Episode {
 id        Int      @id @default(autoincrement())
 title String @unique
 description String
 artwork String
 audio String
 keywords String
 type String
 transcript String
 author   User @relation(fields: [authorId], references: [id])
 authorId Int
 podcast   Podcast @relation(fields: [podcastId], references: [id])
 podcastId Int
}
model RW_DataMigration {
  version    String   @id
  name       String
  startedAt  DateTime
  finishedAt DateTime
}

And the error

Unknown arg `authorId` in data.authorId for type PodcastCreateInput. Did you mean
| Argument tertiaryCategory for data.tertiaryCategory is missing.
 | Argument author for data.author is missing.

The error references “tertiaryCategory” which doesn’t appear in the schema.

Perhaps you had it as a field on Podcast before but removed it?

I’d suggest either running

yarn rw prisma migrate dev

And

yarn rw prisma generate

To update both the schema and client.

I needed to delete .redwood folder. Seems like it was caching error.

1 Like