import { IXPasswordBundleConfig } from "../defs" ; function mutation ( type , mutationLine , others = "" ) { return ( type += "\n type Mutation {\n" + mutationLine + "\n }\n" + others + "\n" ) ; } export default ( config ) => { const { graphql : { mutations } , } = config ; let output = "" ; if ( mutations . register ) { output = mutation ( output , `register(input: RegistrationInput!): RegistrationResponse!` , `
        input RegistrationInput {
          firstName: String!
          lastName: String!
          email: String!
          password: String!
        }

        type RegistrationResponse {
          """
          Please not that if the user is required to validate his email for logging in, token will be null
          """
          token: String
        }
      ` ) ; } if ( mutations . changePassword ) { output = mutation ( output , `changePassword(input: ChangePasswordInput!): Boolean` , `
        input ChangePasswordInput {
          oldPassword: String!
          newPassword: String!
        }
      ` ) ; } if ( mutations . login ) { output = mutation ( output , `login(input: LoginInput!): LoginResponse!` , `
        input LoginInput {
          username: String!
          password: String!
        }
        type LoginResponse {
          token: String!
        }
      ` ) ; } if ( mutations . logout ) { output = mutation ( output , `logout: Boolean` ) ; } if ( mutations . resetPassword ) { output = mutation ( output , `resetPassword(input: ResetPasswordInput!): ResetPasswordResponse!` , `
        input ResetPasswordInput {
          username: String!
          token: String!
          newPassword: String!
        }

        type ResetPasswordResponse {
          token: String!
        }
      ` ) ; } if ( mutations . forgotPassword ) { output = mutation ( output , `forgotPassword(input: ForgotPasswordInput!): Boolean` , `
        input ForgotPasswordInput {
          email: String!
        }
      ` ) ; } if ( mutations . verifyEmail ) { output = mutation ( output , `verifyEmail(input: VerifyEmailInput!): VerifyEmailResponse!` , `
        input VerifyEmailInput {
          username: String
          token: String!
        }

        type VerifyEmailResponse {
          token: String!
        }
      ` ) ; } return output ; } ;