Skip to content

RelationFieldNotFound on nested create/connect #218

Closed

Description

@Errorname

I get a "RelationFieldNotFound" when trying to do a nested create/connect.

The strange thing is that the error says it couldn't found the relation field for "user" on model "Question". But there isn't supposed to be one and I'm not trying to create one.

schema.prisma

datasource db {
  provider = "sqlite"
  url      = "file:default$default.db"
  default  = true
}

generator photon {
  provider = "photonjs"
}

model Question {
  id     String  @default(cuid()) @id @unique
  title  String
  answer Answer?
}

model Answer {
  id       String    @default(cuid()) @id @unique
  content  String
  question Question?
  user     User
}

model User {
  id      String   @default(cuid()) @id @unique
  name    String?
  answers Answer[]
}

index.js

const user = await photon.users.create({
    data: {
      name: 'The User'
    }
  })

  const node = await photon.questions.create({
    data: {
      title: 'The Question',
      answer: {
        create: {
          content: 'The Answer',
          user: {
            connect: {
              id: user.id
            }
          }
        }
      }
    }
  })

  console.log({ node })

Console

DomainError(RelationFieldNotFound { name: "user", model: "Question" })
    at PhotonFetcher.<anonymous> (/Users/errorname/Documents/Vrac/hello-prisma2/nested-create/node_modules/@generated/photon/index.js:34:23)
    at Generator.throw (<anonymous>)
    at rejected (/Users/errorname/Documents/Vrac/hello-prisma2/nested-create/node_modules/@generated/photon/index.js:5:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Activity

  1. changed the title [-]RelationFieldNotFound on nested create[/-] [+]RelationFieldNotFound on nested create/connect[/+] on Jul 23, 2019
  2. Errorname commented on Jul 23, 2019

    @Errorname
    ContributorAuthor

    It looks like a duplicate of prisma/prisma-client-js#33

  3. added
    bug/2-confirmed
    on Jul 23, 2019
  4. added
    bug/1-unconfirmed
    and removed
    bug/2-confirmed
    on Aug 5, 2019
  5. timsuchanek commented on Aug 5, 2019

    @timsuchanek
    Contributor

    @divyenduz please check if the issues are indeed related.

  6. divyenduz commented on Aug 5, 2019

    @divyenduz

    I am able to reproduce this: https://github.com/divyenduz/p2_218

    The following error is observed:

    (node:49200) UnhandledPromiseRejectionWarning: Error: Error in Photon: 
    DomainError(RelationFieldNotFound { name: "user", model: "Question" })
        at PhotonFetcher.<anonymous> (/Users/divyendusingh/Documents/prisma/p2-218/node_modules/@generated/photon/index.js:35:23)
        at Generator.throw (<anonymous>)
        at rejected (/Users/divyendusingh/Documents/prisma/p2-218/node_modules/@generated/photon/index.js:5:65)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    (node:49200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:49200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    
    
  7. divyenduz commented on Aug 5, 2019

    @divyenduz

    I don't think that these are related issues, but @pantharshit00 would post the error message from the issue issue shortly and we can confirm the hypothesis.

  8. added
    bug/2-confirmed
    kind/bug
    and removed
    bug/1-unconfirmed
    on Aug 5, 2019
  9. mavilein commented on Aug 8, 2019

    @mavilein
    Contributor

    This is fixed in binary version b8957df02bca6708b7aefa56832eda409dbb1114 which is available on alpha.

  10. added this to the Preview 6 milestone on Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug/2-confirmedkind/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions