Commit 7bf4b80d authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Skip redaction for skipped fields

Subscriptions can sometimes return GraphQL::Execution::Execute::SKIP
when there is no update
parent 44fb7c26
...@@ -37,6 +37,8 @@ module Gitlab ...@@ -37,6 +37,8 @@ module Gitlab
end end
def after_resolve(value:, context:, **rest) def after_resolve(value:, context:, **rest)
return value if value.is_a?(GraphQL::Execution::Execute::Skip)
if @field.connection? if @field.connection?
redact_connection(value, context) redact_connection(value, context)
elsif @field.type.list? elsif @field.type.list?
......
...@@ -376,6 +376,26 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do ...@@ -376,6 +376,26 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do
end end
end end
describe 'Authorization on GraphQL::Execution::Execute::SKIP' do
let(:type) do
type_factory do |type|
type.authorize permission_single
end
end
let(:query_type) do
query_factory do |query|
query.field :item, [type], null: true, resolver: new_resolver(GraphQL::Execution::Execute::SKIP)
end
end
it 'skips redaction' do
expect(Ability).not_to receive(:allowed?)
result
end
end
private private
def permit(*permissions) def permit(*permissions)
......
...@@ -112,7 +112,7 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do ...@@ -112,7 +112,7 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do
subject(:projects) { resolve_projects(args) } subject(:projects) { resolve_projects(args) }
let(:include_subgroups) { false } let(:include_subgroups) { false }
let(:project_3) { create(:project, name: 'Project', path: 'project', namespace: namespace) } let!(:project_3) { create(:project, name: 'Project', path: 'project', namespace: namespace) }
context 'when ids is provided' do context 'when ids is provided' do
let(:ids) { [project_3.to_global_id.to_s] } let(:ids) { [project_3.to_global_id.to_s] }
......
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