Skip to content

Commit

Permalink
update resolver to allow for orcid as ID arg
Browse files Browse the repository at this point in the history
  • Loading branch information
thinknoack committed Dec 19, 2024
1 parent 71e26f2 commit 01ecc53
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/openneuro-server/src/graphql/resolvers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import User from "../../models/user"



export const user = (obj, { id, orcid }) => {
if (id) {
return User.findOne(id).exec()
export const user = (obj, { id }) => {

function isValidOrcid(orcid: string): boolean {
return /^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]$/.test(orcid || '');
}
if (orcid) {
return User.findOne(orcid).exec()

if (isValidOrcid(id)) {
return User.findOne({ "orchid": id }).exec()
} else {
return User.findOne({ 'id': id }).exec()
}

Check warning on line 19 in packages/openneuro-server/src/graphql/resolvers/user.ts

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-server/src/graphql/resolvers/user.ts#L9-L19

Added lines #L9 - L19 were not covered by tests
}

export const users = (obj, args, { userInfo }) => {
Expand Down

0 comments on commit 01ecc53

Please sign in to comment.