Sha256: 92950c07cd1616440be24874a7abeb7ba61bb11a5882ec5b25b3a0b0187bbb3f

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

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

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

    def resolve(_args)
      token = repo.generate_custom_token!

      graphql_returning(token)
    end

    private

    def normalize_parameters
      attribute_params.permit(:code, :redirect_uri)
    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

1 entries across 1 versions & 1 rubygems

Version Path
ibrain-auth-0.3.15 app/graphql/ibrain/mutations/generate_firebase_token_mutation.rb