Commit 20b17704 authored by Alex Kalderimis's avatar Alex Kalderimis

Take inheritance into account when presenting fields

parent 8eed9590
---
title: Fix regression in GraphQL field MergeRequest.assignees.webUrl
merge_request: 60428
author:
type: fixed
......@@ -10,14 +10,14 @@ module Gitlab
end
def self.presenter_class
@presenter_class
@presenter_class || superclass.try(:presenter_class)
end
def self.present(object, attrs)
klass = @presenter_class
klass = presenter_class
return object if !klass || object.is_a?(klass)
@presenter_class.new(object, **attrs)
klass.new(object, **attrs)
end
end
......
......@@ -63,6 +63,16 @@ RSpec.describe Gitlab::Graphql::Present::FieldExtension do
expect(value).to eq 'made of concrete'
end
context 'when the implementation is inherited' do
it 'resolves the interface field using the implementation from the presenter' do
subclass = Class.new(implementation) { graphql_name 'Subclass' }
field = ::Types::BaseField.new(name: :interface_field, type: GraphQL::STRING_TYPE, null: true, owner: interface)
value = resolve_field(field, object, object_type: subclass)
expect(value).to eq 'made of concrete'
end
end
end
describe 'interactions with inheritance' do
......
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