Prisma1: Prisma Deploy – generated prisma.graphql file is commented out halfway through

Created on 20 Mar 2018  Â·  3Comments  Â·  Source: prisma/prisma1

Bug Report

Current behavior

The generated prism.graphql file gets commented out halfway through:

screen shot 2018-03-20 at 12 26 36 pm

Reproduction

screen shot 2018-03-20 at 12 27 16 pm

screen shot 2018-03-20 at 12 27 01 pm

screen shot 2018-03-20 at 12 36 48 pm

screen shot 2018-03-20 at 12 38 16 pm

Expected behavior?

I'm trying to run a simple query to get the user with a given facebookID. For now, I forward the given user query to the db, and call it like this:

let user = await ctx.db.query.user({ where : { facebookId : facebookUser.id } })

It's giving me this error message: "Variable \"$_where\" got invalid value {\"facebookId\":\"1066677483399188\"}; Field \"facebookId\" is not defined by type UserWhereUniqueInput."

Please help me fix this! I believe this to be a bug related to the auto-generated file... but maybe I've also wrongly implemented it (I'm very new to Prisma). What do I do?

Most helpful comment

Hey @harrysolovay, you are encountering two separate problems.

You receive this error message because your User type does not specify the facebookId to be @unique. Please change line 8 indatamodel.graphql to

facebookId!: String @unique

then prisma deploy and let it regenerate the prisma.ts file. Your original code should then work as expected.

The cosmetic problem has been brought up before by @johannpinson here. He concluded that this requires a change in the graphql-js library, and added a new issue for this here. Please join the discussion there, to raise awareness about this problem 🙂

Let me know if you need further help with your first issue.

All 3 comments

Just noticed that I wasn't using UserWhereInput and not UserWhereUniqueInput, which I then changed. I also adjusted my query to the following:

user(parent, args, ctx, info) {
  return ctx.db.query.user({
    where : {
      facebookId
    }
  }, info)
}

I'm still getting an error: "Variable \"$_where\" got invalid value {\"facebookId\":\"1066677483399188\"}; Field \"facebookId\" is not defined by type UserWhereUniqueInput."

Hey @harrysolovay, you are encountering two separate problems.

You receive this error message because your User type does not specify the facebookId to be @unique. Please change line 8 indatamodel.graphql to

facebookId!: String @unique

then prisma deploy and let it regenerate the prisma.ts file. Your original code should then work as expected.

The cosmetic problem has been brought up before by @johannpinson here. He concluded that this requires a change in the graphql-js library, and added a new issue for this here. Please join the discussion there, to raise awareness about this problem 🙂

Let me know if you need further help with your first issue.

Worked like a charm! Thank you!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoodsy picture hoodsy  Â·  3Comments

thomaswright picture thomaswright  Â·  3Comments

akoenig picture akoenig  Â·  3Comments

AlessandroAnnini picture AlessandroAnnini  Â·  3Comments

nikolasburk picture nikolasburk  Â·  3Comments