fs / rails-base-graphql-api

Base Rails application for GraphQL API
27 stars 7 forks source link

Need to provide authenticated user to context in SignIn and SignUp mutation #222

Open Vadim-Kurnatovskiy opened 2 years ago

Vadim-Kurnatovskiy commented 2 years ago

This error can be reproduced if you request additional policy rules for the user when logging in

module Mutations
  class SignIn < BaseMutation
    argument :input, Types::SignInInput, required: true

    type Types::Payloads::SignInPayload

    def resolve(input:)
      signin_user = SigninUser.call(input.to_h)

      if signin_user.success?
        context[:current_user] = result.user

        signin_user
      else
        execution_error(error_data: signin_user.error_data)
      end
    end
  end
end

co-authored @AnnaAleynik