Sha256: 82abe80a62708da209a5dae81fdbb4be8ee9dfa0c49969c6c17a9976b1a8f5f9

Contents?: true

Size: 757 Bytes

Versions: 8

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

module Ibrain::Auth::Mutations
  class GenerateFirebaseTokenMutation < BaseMutation
    field :result, Boolean, null: true
    field :token, String, null: true

    argument :attributes, ::Ibrain::Auth::Types::Input::GenerateFirebaseTokenInput, required: true

    def resolve(_args)
      token = repo.generate_custom_token!

      graphql_returning(token)
    end

    private

    def normalize_parameters
      attribute_params.permit(:uid)
    rescue StandardError
      ActionController::Parameters.new({})
    end

    def repo
      ::FirebaseRepository.new(nil, normalize_parameters)
    end

    def graphql_returning(token)
      OpenStruct.new(
        token: token,
        result: true
      )
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ibrain-auth-0.3.7 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
ibrain-auth-0.3.6 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
ibrain-auth-0.3.5 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
ibrain-auth-0.3.4 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
ibrain-auth-0.3.3 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
ibrain-auth-0.3.2 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
ibrain-auth-0.3.1 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb
ibrain-auth-0.2.7 app/graphql/ibrain/auth/mutations/generate_firebase_token_mutation.rb