# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

module Gql::Types
  class Policy::DefaultType < Gql::Types::BaseObject
    include Gql::Types::Policy::Concerns::HasPunditQueries

    description 'Access Pundit policy queries for the current object and user.'

    # `read` is implicit, as the record cannot be fetched without it.
    field :update, Boolean, null: false, description: 'Is the user allowed to update this object?'
    field :destroy, Boolean, null: false, description: 'Is the user allowed to delete this object?'

    def update
      pundit(:update?)
    end

    def destroy
      pundit(:destroy?)
    end
  end
end
