Probably a dumb question. I've been following the...
# orm-help
k
Probably a dumb question. I've been following the HowToGraphQL guides with node and I've started getting messages like this " "message": "Variable '$_v0_data' expected value of type 'UserCreateInput!' " and I've no idea what it means. Any clues?
n
does it say in which file or at what point you get this error? Is it when you try to deploy your datamodel?
k
I'm using playground to try and populate some data
I believe it's deployed ok. I can see it in playground on the server side.
Also getting this: Reason: 'email' Field 'email' is not defined in the input type 'UserCreateInput'. (line 1, column 11):\nmutation ($_v0_data: UserCreateInput!) {\n ^",
n
does your User in the datamodel has a field called email? e.g.:
Copy code
type User {
email: String!
}
hope this code styling works, i'm pretty new to this haha
It seems like your server is missing the email field in some graphql file. Try to redeploy and refetch your generated schema with the get-schema command, maybe this will help 🙂
k
here is what's in database/datamodel.graphql
Copy code
type User {
  id: ID! @unique
  name: String!
  email: String! @unique
  password: String!
  circuits: [Circuit!]!
  sends: [Send!]!
  homegym: Gym
}
and here is what's in the other datamodel file: ``type User { id: ID! name: String! email: String! circuits: [Circuit!]! }11
I'm not very good at this formatting 😄
n
It seems you have to use 3x `` on the beginning and 3x `` at the end for the formatting 😄 (3x one apostrophe)
k
Copy code
test

{  }
🦜 1
ah ha!
fast parrot 1
n
on the playground you can see the schemas available on the right. Clicke there on CreateUser. There should be something in the
Arguments
category. It should be from type
UserCreateInput!
. If you click on this, is there a email field as well?
it should look like something like this:
Copy code
type UserCreateInput {
username: String!
email: String!
password: String!
//Some more field here maybe
}
k
Copy code
data: UserCreateInput!
type UserCreateInput {
name: String!
email: String!
password: String!
circuits: CircuitCreateManyWithoutAddedByInput
sends: SendCreateManyWithoutUserInput
homegym: GymCreateOneInput
}
n
can you send the mutation command you try to populate your DB with?
k
one sec
👍 1
This is what I've got in my Mutation.js resolver:
Copy code
async function signup(parent, args, context, info) {
  const password = await bcrypt.hash(args.password, 10)
  const user = await context.db.mutation.createUser({
    data: { ...args, password },
  }, `{ id }`)

  const token = jwt.sign({ userId: user.id }, APP_SECRET)

  return {
    token,
    user,
  }
}
I
I've been dipping in and out and understanding what it's asking me to do, but not really the bigger picture of the whole thing 😕
n
yeah i took this tutorial as well and i think it's a bit hard for graphql beginners (especially when it comes to authentication). I then took the udemy course from Andrew Mead about GraphQL, which helped me a lot in understanding the features of it ^^. Look into the schema.graphql file and search for the CreateUserInput input type. Does it have an email field as well? With the code fetching you actually try to fetch from the generated graphql file, while from playground you fetch directly from the database. On which server and port is your application running? Windows / Mac? Are you using docker for this or plain Prisma so to say?
sry, didn't mean the schema.graphql, i've meant the prisma.graphql (i think it's called. The generated graphql file from the get-schema command)
k
I might get the tutorial! Thanks 😄
Copy code
type Mutation {
  createNewsarticle(data: NewsarticleCreateInput!): Newsarticle!
  createUser(data: UserCreateInput!): User!
It's there.
n
there must be something like:
Copy code
type UserCreateInput {
data {...}
}
in there. Need to see the contents of it 🙂
ah sry i've meant input UserCreateInput, not type UserCreateInput 😄
k
Oh sorry! Didn't look far enough:
Copy code
input UserCreateInput {
  name: String!
  email: String!
  password: String!
  circuits: CircuitCreateManyWithoutAddedByInput
  sends: SendCreateManyWithoutUserInput
  homegym: GymCreateOneInput
}
n
ah thanks
do you have a github version of this or something so i can look and test it myself?
it's really odd, because it says email field is not declared at some point, but it clearly is. Maybe you are doing a request to the wrong server or you pass wrong arguments 🤔
k
I haven't really changed much in the code either.
I might just nuke it and redo from start! I feel like I've just broken something without realising it
👍 1
n
could be. Sorry that i couldn't help you with it 😅
👍 1
k
That's fine. Thanks for looking though, It's kinda reassuring that it isn't something stupid and obvious... Right, 4th time through this tutorial again!
👍 1
n
thanks, good luck with the tutorial 🙂 if you keep getting stuck however, better consider another tutorial (be careful, there are lots of tutorials on youtube which are actually outdated or also quite complex).
k
Yeah. the issue isn't that I get stuck, more than I finish it, and then it all falls apart when I actually try and build something. I'll get there. I'll check out the udemy one