Commit c153ce12 authored by Brett Walker's avatar Brett Walker

Remove use of accepts_definition

as it’s deprecated in graphql 1.13.12 and removed
in 2.x
parent 46b38736
......@@ -9,6 +9,11 @@ module Types
field_class Types::BaseField
edge_type_class Types::BaseEdge
def self.authorize(*args)
@authorize_args = args if args.any?
@authorize_args || (superclass.respond_to?(:authorize) ? superclass.authorize : nil)
end
def self.accepts(*types)
@accepts ||= []
@accepts += types
......
# frozen_string_literal: true
GraphQL::ObjectType.accepts_definitions(authorize: GraphQL::Define.assign_metadata_key(:authorize))
GraphQL::Schema::Object.accepts_definition(:authorize)
......@@ -428,5 +428,26 @@ RSpec.describe Types::BaseObject do
expect(result.dig('data', 'users', 'nodes'))
.to contain_exactly({ 'name' => active_users.first.name })
end
describe '.authorize' do
let_it_be(:read_only_type) do
Class.new(described_class) do
authorize :read_only
end
end
let_it_be(:inherited_read_only_type) { Class.new(read_only_type) }
it 'keeps track of the specified value' do
expect(described_class.authorize).to be_nil
expect(read_only_type.authorize).to match_array [:read_only]
expect(inherited_read_only_type.authorize).to match_array [:read_only]
read_only_type.authorize(:write_only)
expect(read_only_type.authorize).to match_array [:write_only]
expect(inherited_read_only_type.authorize).to match_array [:write_only]
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment