Commit ab3c3fed authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '32933-graphql-remove-deprecated-method-of-decoding-cursors' into 'master'

GraphQL: remove deprecated method of decoding cursors

See merge request gitlab-org/gitlab!20496
parents cc4693d1 e3183bd0
......@@ -137,14 +137,7 @@ module Gitlab
def ordering_from_encoded_json(cursor)
JSON.parse(decode(cursor))
rescue JSON::ParserError
# for the transition period where a client might request using an
# old style cursor. Once removed, make it an error:
# raise Gitlab::Graphql::Errors::ArgumentError, "Please provide a valid cursor"
# TODO can be removed in next release
# https://gitlab.com/gitlab-org/gitlab/issues/32933
field_name = order_list.first.attribute_name
{ field_name => decode(cursor) }
raise Gitlab::Graphql::Errors::ArgumentError, "Please provide a valid cursor"
end
end
end
......
......@@ -218,23 +218,11 @@ describe Gitlab::Graphql::Connections::Keyset::Connection do
end
end
# TODO Enable this as part of below issue
# https://gitlab.com/gitlab-org/gitlab/issues/32933
# context 'when an invalid cursor is provided' do
# let(:arguments) { { before: 'invalidcursor' } }
#
# it 'raises an error' do
# expect { expect(subject.sliced_nodes) }.to raise_error(Gitlab::Graphql::Errors::ArgumentError)
# end
# end
# TODO Remove this as part of below issue
# https://gitlab.com/gitlab-org/gitlab/issues/32933
context 'when an old style cursor is provided' do
let(:arguments) { { before: Base64Bp.urlsafe_encode64(projects[1].id.to_s, padding: false) } }
context 'when an invalid cursor is provided' do
let(:arguments) { { before: Base64Bp.urlsafe_encode64('invalidcursor', padding: false) } }
it 'only returns the project before the selected one' do
expect(subject.sliced_nodes).to contain_exactly(projects.first)
it 'raises an error' do
expect { subject.sliced_nodes }.to raise_error(Gitlab::Graphql::Errors::ArgumentError)
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