Skip to content

Commit e5315ec

Browse files
authored
Merge pull request #676 from MITLibraries/timx-197-record-not-found
Provide message when record not found
2 parents 110a859 + 6737dea commit e5315ec

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed

app/graphql/types/query_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def info
3838
def record_id(id:, index:)
3939
result = Retrieve.new.fetch(id, Timdex::OSClient, index)
4040
result['hits']['hits'].first['_source']
41-
rescue Elasticsearch::Transport::Transport::Errors::NotFound
41+
rescue OpenSearch::Transport::Transport::Errors::NotFound
4242
raise GraphQL::ExecutionError, "Record '#{id}' not found"
4343
end
4444

test/controllers/graphql_controller_v2_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,22 @@ def setup
331331
end
332332
end
333333

334+
test 'graphqlv2 retrieve with not found recordid' do
335+
VCR.use_cassette('graphql v2 retrieve not found') do
336+
post '/graphql', params: { query: '{
337+
recordId(id: "totallylegitrecordid") {
338+
timdexRecordId
339+
title
340+
}
341+
}' }
342+
assert_equal(200, response.status)
343+
json = JSON.parse(response.body)
344+
assert_nil(json['data'])
345+
assert_equal("Record 'totallylegitrecordid' not found", json['errors'].first['message'])
346+
end
347+
end
348+
349+
334350
test 'graphqlv2 holding location is not required' do
335351
VCR.use_cassette('graphql v2 location') do
336352
post '/graphql', params: { query: '{

test/vcr_cassettes/graphql_v2_retrieve_not_found.yml

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)