Commit ac178f16 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'skip-graphql-redaction-for-graphql-skip' into 'master'

Skip GraphQL redaction for skipped fields

See merge request gitlab-org/gitlab!59627
parents 3e1bf200 7bf4b80d
......@@ -37,6 +37,8 @@ module Gitlab
end
def after_resolve(value:, context:, **rest)
return value if value.is_a?(GraphQL::Execution::Execute::Skip)
if @field.connection?
redact_connection(value, context)
elsif @field.type.list?
......
......@@ -376,6 +376,26 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do
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
def permit(*permissions)
......
......@@ -112,7 +112,7 @@ RSpec.describe Resolvers::NamespaceProjectsResolver do
subject(:projects) { resolve_projects(args) }
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
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