No Node for the model User with value 5c87b80efec496584da9fbf3 for id found


#1

I am getting the error but it is not descriptive, the user exists in the database, there is my code:

Mutation:

createPurchase(
    purchase: String!
    address: String!
    comments: String!
    serviceDate: String!
): Purchase

Resolver:

async function createPurchase(root, args, context) {
      const userID = getUserId(context);
      console.log("CREATEPURCHASE", userID);
      if (!userID) {
        throw new Error("Not authenticated");
      }
      const createdAt = new Date();
        return await context.prisma.createPurchase({
          user: { connect: { id: userID } },
          purchase: args.purchase,
          address: args.address,
          createdAt,
          comments: args.comments,
          serviceDate: args.serviceDate
        });
}

DataModel:

      type Purchase {
        id: ID! @id
        user: User! @relation(link: INLINE)
        professional: String
        purchase: String!
        comments: String
        address: String!
        serviceDate: DateTime
        createdAt: DateTime!
        ended: Boolean @default(value: false)
      }

  type User {
    id: ID! @id
    name: String!
    email: String! @unique
    phone: String
    secretop: String!
    avatar: String
    createdAt: DateTime!
    purchases: [Purchase]
    pushtoken: String
    role: String @default(value: "user")
    location: Json
    recover_code: String
    verify_code: String
    active: Boolean @default(value: true)
  }

for me, the error is not clear.


#2

Hey, can you please also post your docker-compose.yml?


#3

sure:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.26
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: mongo
            uri: >-
              mongodb+srv:**********

#4

Can you update your Prisma version to 1.28.3 and quickly check whether the error is still there. We had a fix for Mongo since then and I just want to be sure this did not already cover it.


#5

Still the same, I’ve already updated the Prisma, restarted the docker, restarted the pm2 and run again the mutation with no success.


#6

Ok, then I’ll look into it.


#7

Would you please explain the error message, it happens because… maybe if i understand the error i can get a light.


#8

Well the error message states that Prisma was trying to do the connect with the Information you provided. It was looking for a User with the id 5c… but could not find it. Then it errors.

I tried reproducing the problem locally, but for me it worked.

Could you run docker ps in the terminal and post the output please?


#9

weird, because I look with that same id, and the user exists, here is the

docker ps

CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                    NAMES
    9b6503010bb2        prismagraphql/prisma:1.28.3   "/bin/sh -c /app/sta…"   16 minutes ago      Up 15 minutes       0.0.0.0:4466->4466/tcp   backend_prisma_1

#10

@epileftro85 Can you please dump the data in your database using prisma export and share that here or find me in our slack at slack.prisma.io, my username there is divyenduz.


#11

Export is not yet supported for document stores.

i will give you a repo if you want to look at it


#12

I am more interested in seeing the actual data in the underlying database. Can you provide me temporary access to the database itself?

Does a normal query on user with this id return the data correctly?


#13

Which way should I send to you the exported data?


#14

singh@prisma.io or join our slack at slack.prisma.io


#15

Sent to email. Thank you in advance.


#16

@epileftro85

I am unable to reproduce this. I even restored the export you have sent to @Divyendu_Singh

image

I am using prisma version 1.28.3. I am using the following script to reproduce:

const { prisma } = require('./generated/prisma-client')

async function main() {
  let test = await prisma.createPurchase({
    user: { connect: { id: '5c87b80efec496584da9fbf3' } },
    purchase: 'asd',
    address: 'asd',
    comments: 'asd',
    createdAt: new Date().toISOString(),
    serviceDate: new Date().toISOString(),
  })

  console.log(test)
}

main()


#17

Thanks for your time, I will keep looking what would be if I find something I will update the answer. :+1:


#18

Hi All, it was my bad, turns out that I am mixing mongoose on the user creation because I need to use geoLocation, and Prisma is not ready yet to GeoJson Objects ( according to the docs ), so, my document was named users instead User. That was why the Prisma was not founding any user with the id. Thank you all for your time, and sorry for the false alarm. @pantharshit00 @Divyendu_Singh @do4gr


#19

Thanks for informing us. Happy that it worked out for you.