Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip out orcid url scheme for people search #1014

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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