Kyle (TechSquidTV)
08/29/2021, 5:32 PMtype 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
// 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:
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
export class New_T_User {
id: string;
name: string;
email?: Nullable<string>;
}
Any help is appreciated thank you.Ryan
09/06/2021, 5:16 AMNew_T_User
TypeScript type doesn’t match your GraphQL input
type. Are they the same?