This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Description
When calling authorize, the 'parent object' passed to the policy is not an instance of the relevant model, it is instead an instance of the object type.
# Gemfile
gem 'graphql-pundit', '~> 0.7.1'
...
class Types::BaseObject < GraphQL::Schema::Object
field_class GraphQL::Pundit::Field
end
...
class AppSchema < GraphQL::Schema
query Types::Query
end
...
class Types::Query < Types::BaseObject
field :current_user, Types::User, null: true
def current_user
context[:current_user]
end
end
...
class Types::User < Types::BaseObject
field :test_pundit, String, null: true do
authorize ->(obj, args, ctx) {
binding.pry
# obj.class => Types::User
# obj.object.class => User
}
end
# compare with class of obj as passed to resolver.
field :test, String, null: true, resolve: ->(obj, args, ctx) {
binding.pry
# obj.class => User
}
end