<@U0RQY0KK5>, I have token field in my user model ...
# prisma-whats-new
p
@nilan, I have token field in my user model before the User save i need to generate random token and save this in token filed in user model Can you tell me how can i do?
✅ 1
n
@ppatidar you can use a function in the request pipeline step
TRANSFORM_ARGUMENTS
p
type User implements Node { address: String athlete: Athlete @relation(name: "UserOnAthlete") auth0UserId: String @isUnique bio: String coache: Coache @relation(name: "CoacheOnUser") country: String createdAt: DateTime! createdAthletes: [Athlete!]! @relation(name: "CreatedAthlete") dob: DateTime email: String! @isUnique emailVerified: Boolean! @defaultValue(value: false) firstName: String! gender: String height: Float id: ID! @isUnique instituteOwner: Institute @relation(name: "InstituteOnUser") isActive: Boolean! @defaultValue(value: false) isFirstTimeLogin: Boolean! @defaultValue(value: false) lastName: String! manager: Manager @relation(name: "ManagerOnUser") messageCount: Int! @defaultValue(value: 0) mobileNumber: String mobileVerificationCode: String mobileVerified: Boolean! @defaultValue(value: false) nationality: String notificationCount: Int! @defaultValue(value: 0) password: String profileImage: String resetPassword: ResetPassword @relation(name: "ResetPasswordOnUser") role: UserRole! timeZone: String updatedAt: DateTime! weight: Float }
type ResetPassword implements Node { createdAt: DateTime! id: ID! @isUnique token: String! updatedAt: DateTime! user: User! @relation(name: "ResetPasswordOnUser") }
In the function module.exports = function (input, log, cb) { data = input.data data.resetPassword = {token:"token123456789"} return {data: data} }
api call mutation { createUser(authProvider: {auth0: {idToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3Jhaml2LmF1LmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1OTFjNjc2MWM3MWFiMjM0YzZhOTRjODUiLCJhdWQiOiJvNHFVNk10RDRUMzNHZ2ZhbmQ4OHlzMnI0aHNvTVl5NiIsImV4cCI6MTQ5NTA2OTcwMCwiaWF0IjoxNDk1MDMzNzAwfQ.Ha_x3DBHbcRN_YpKelMeaarApimTlHRWwKtL_VO3OIA"}} email: "athlete13@miniche.com" firstName: "athlete13" lastName: "athlete13" role: ATHLETE athlete: { status: APPROVED } ) { id } }
Its not working
nothing happend i want to set resetpassword token befor the save user model
n
why don't you have a
token
String on the
User
type itself?
p
i dont want to send this from api call but want to save it automatci before the save
n
Yes, you can also modify the token in the function, without sending it in the API call itself
p
How?
can you provide me one example?