radar/twist-v2

View on GitHub
backend/lib/twist/web/graphql/resolvers/book.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Twist
  module Web
    module GraphQL
      module Resolvers
        class Book < Resolver
          def resolve(permalink:)
            book = context[:book_repo].find_by_permalink(permalink)
            authorization = Authorization::Book.new(
              book: book,
              user: current_user,
              permission_repo: context[:permission_repo],
            )

            return book if authorization.success?

            authorization
          end
        end
      end
    end
  end
end