Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not convert prisma value to graphqlid #348

Closed
dortamiguel opened this issue Aug 9, 2019 · 6 comments
Closed

Could not convert prisma value to graphqlid #348

dortamiguel opened this issue Aug 9, 2019 · 6 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.

Comments

@dortamiguel
Copy link

After the update I have a piece of code that stoped working.

I'm creating the uuid with the npm library 'uuid/v1' before calling create but it looks like it not longer works.

This is the datamodel

model Vault {
  id String @id @default(uuid())
  createdAtTick Int
  x Int
  y Int
  userId String?
  resourceId String
  facilityId String
}

This is the code

import uuidv1 from 'uuid/v1';
import Photon from 'server/photon';

const photon = new Photon();

const main = async () => {
  await photon.vaults.create({
    data: {
      id: uuidv1(),
      createdAtTick: 0,
      x: 1,
      y: 1,
      resourceId: uuidv1(),
      facilityId: uuidv1(),
    },
  });
};

main();

And this is the error message

It occured in the `photon.()` invocation in /Users/miguel/src/vault/src/server/index.ts:7:23

   3
   4 const photon = new Photon();
   5
   6 const main = async () => {
→  7   await photon.vaults.create({

Reason: Could not convert prisma value to graphqlid: ConversionFailure("PrismaValue", "PrismaValue::GraphqlId") in src/libcore/result.rs:997:5

Please create an issue in the photonjs repo with
your `schema.prisma` and the Photon method you tried to use 🙏:
https://github.com/prisma/photonjs/issues/new

    at PhotonFetcher.<anonymous> (/Users/miguel/src/vault/src/server/photon/index.js:46:27)
    at Generator.throw (<anonymous>)
    at rejected (/Users/miguel/src/vault/src/server/photon/index.js:5:47)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)

Also if a comment the line that specifies the id on the create object I get this other error

Invalid `photon.()` invocation in /Users/miguel/src/vault/src/server/index.ts:7:23

   3
   4 const photon = new Photon();
   5
   6 const main = async () => {
→  7   await photon.vaults.create(

Reason: Error in connector: Error querying the database: error serializing parameter 0: cannot convert to or from a Postgres value of type `text`

Looks like if you pass an uuid to a field that is a String on the datamodel photon throws an error.

@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. labels Aug 12, 2019
@pantharshit00
Copy link
Contributor

pantharshit00 commented Aug 12, 2019

I can confirm this

Reproduction repository: https://github.com/harshit-test-org/issue-prisma2-348

@cloverich
Copy link

Adding a comment per my my thread with divyendu. I had a similar error creating this model:

model Install {
  id String @id @default(cuid()) @unique
  platform String?
  account Account?
  createdAt DateTime @default(now())
}

Manually changing the id would cause it to work:

// this id fails
bef4782946fdd5346810e9c72b289b8f

// these work (changing only first character)
cef4782946fdd5346810e9c72b289b8f
1ef4782946fdd5346810e9c72b289b8f

@warrenday
Copy link

Also had same issue with trying to create a record with a uuid after upgrading prisma2 to 2.0.0-preview-6.1 - issue not present in preview-5

@dortamiguel
Copy link
Author

dortamiguel commented Sep 7, 2019

Any news on this?

This is a blocker for me

@warrenday
Copy link

warrenday commented Sep 7, 2019

The issue is resolved in preview-7 and above. @ellipticaldoor

@dortamiguel
Copy link
Author

Awesome thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

4 participants