-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding a fetchByUserId admin endpoint (#3401)
Co-authored-by: Nicolas Burtey <[email protected]>
- Loading branch information
1 parent
8e7c0ec
commit 58eb8d1
Showing
7 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
core/api/src/graphql/admin/root/query/account-details-by-user-id.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { GT } from "@/graphql/index" | ||
|
||
import AuditedAccount from "@/graphql/admin/types/object/account" | ||
import { mapError } from "@/graphql/error-map" | ||
|
||
import { Admin } from "@/app" | ||
|
||
const AccountDetailsByUserId = GT.Field({ | ||
args: { | ||
userId: { type: GT.NonNullID }, | ||
}, | ||
type: GT.NonNull(AuditedAccount), | ||
resolve: async (_, { userId }) => { | ||
if (userId instanceof Error) { | ||
throw userId | ||
} | ||
|
||
const account = await Admin.getAccountByUserId(userId) | ||
if (account instanceof Error) { | ||
throw mapError(account) | ||
} | ||
|
||
return account | ||
}, | ||
}) | ||
|
||
export default AccountDetailsByUserId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
core/api/test/bats/admin-gql/account-details-by-account-id.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
query accountDetailsByAccountId($accountId: ID!) { | ||
accountDetailsByAccountId(accountId: $accountId) { | ||
id | ||
owner { | ||
id | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
query accountDetailsByUserId($userId: ID!) { | ||
accountDetailsByUserId(userId: $userId) { | ||
id | ||
owner { | ||
id | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters