Hey folks. Trying out prisma again, following a tu...
# prisma-client
k
Hey folks. Trying out prisma again, following a tutorial here. I'm having an issue with creating an entry. In my schema.graphql file:
Copy code
type T_User {
  id: ID!
  name: String!
  email: String
  oauth_token: String
  oauth_token_secret: String
}

input New_T_User {
  name: String!
  email: String
  oauth_token: String
  oauth_token_secret: String
}
...
type mutation {
  create_t_user(input: New_T_User!): T_User!
  update_t_user(input: Update_T_User): T_User
  delete_t_user(id: ID!): T_User
}
Now, I am creating the function which will create a new user but I am running into this typing issue. This comes from the area of the tutorial headed with
Adding post service
Copy code
// Create a new user
  async createUser(newUser: New_T_User): Promise<T_User> {
    return this.prisma.t_user.create({
      data: newUser
    })
  }
data
here is reporting an error as
New_T_User
is not assignable. full error:
Copy code
Type 'New_T_User' is not assignable to type '(Without<t_userCreateInput, t_userUncheckedCreateInput> & t_userUncheckedCreateInput) | (Without<...> & t_userCreateInput)'.
  Type 'New_T_User' is not assignable to type 'Without<t_userUncheckedCreateInput, t_userCreateInput> & t_userCreateInput'.
    Type 'New_T_User' is not assignable to type 't_userCreateInput'.
      Property 'email' is optional in type 'New_T_User' but required in type 't_userCreateInput'.ts(2322)
So here we see that
email
is optional in
New_T_User
, which, is expected. But it is somehow required in
't_userCreateInput'.ts
< im not sure exactly where this file is But I assume it comes from the generated prisma client. In my generated graphql.js file we can see email is an optional and nullable string
Copy code
export class New_T_User {
    id: string;
    name: string;
    email?: Nullable<string>;
}
Any help is appreciated thank you.
r
Your
New_T_User
TypeScript type doesn’t match your GraphQL
input
type. Are they the same?