Skip to content

Commit

Permalink
Merge pull request #1014 from datacite/strip-orcid-url-scheme-out-on-…
Browse files Browse the repository at this point in the history
…person-search

strip out orcid url scheme for people search
  • Loading branch information
wendelfabianchinsamy authored Oct 3, 2023
2 parents 1e1c746 + 4c061ec commit ee4b505
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ def person(id:)
end

def people(**args)
response = Person.query(args[:query], limit: args[:first], offset: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil)
query = args[:query].gsub(/^https?:\/\//, "")
response = Person.query(query, limit: args[:first], offset: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil)
HashConnection.new(response, context: context, first: args[:first], after: args[:after])
end

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions spec/graphql/types/person_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,4 +599,34 @@
# )
# end
# end

describe "query people with absolute orcid uri", elasticsearch: true, vcr: true do
let(:query) do
"query asdfsadfa {
people(first: 25, query: \"https://orcid.org/0000-0001-5727-2427\", after: null) {
totalCount
pageInfo {
endCursor
hasNextPage
__typename
}
nodes {
id
name
givenName
familyName
alternateName
__typename
}
__typename
}
}"
end

it "returns success response" do
response = LupoSchema.execute(query).as_json

expect(response.dig("data", "errors")).to(eq(nil))
end
end
end

0 comments on commit ee4b505

Please sign in to comment.