Class: Mutations::Auth::SignUp
- Inherits:
-
GraphQL::Schema::Mutation
- Object
- GraphQL::Schema::Mutation
- Mutations::Auth::SignUp
- Includes:
- Graphql::TokenHelper
- Defined in:
- app/graphql/mutations/auth/sign_up.rb
Overview
mutation {
signUp(email: "[email protected]", password: "password", passwordConfirmation: "password") {
success
user {
email
}
errors {
field
}
}
}
Instance Method Summary collapse
Methods included from Graphql::TokenHelper
#delete_refresh_token, #generate_access_token, #set_refresh_token
Instance Method Details
#resolve(args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/graphql/mutations/auth/sign_up.rb', line 35 def resolve(args) response = context[:response] user = User.new args if user.save generate_access_token(user, response) { errors: [], success: true, user: user } else { errors: user.errors..map do |field, | { field: field.to_s.camelize(:lower), message: .first.capitalize } end, success: false, user: nil, } end end |