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

feat: Use $api client for requests from Hasura → API #2297

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Oct 12, 2023

What does this PR do?

  • Replace the "god mode" $admin client with the $api client (see comment on naming conventions) which is scoped to the "api" role
  • All the functions updated here are behind the useHasuraAuth() auth middleware - these functions are all triggered by Hasura

What about tests?

Yep, this is tricky. Introspection tests cover the permissions the $api client has here. Some of the functionality is covered by E2E tests (send, invite to pay) - some is not (submit, export).

I think the best solution here in the medium term is to probably work to improve our E2E test coverage for high-priority functionality.

@DafyddLlyr DafyddLlyr changed the base branch from main to dp/admin-api-permissions October 12, 2023 07:23
@DafyddLlyr DafyddLlyr force-pushed the dp/use-api-client-for-useHasuraAuth branch from 166fa8e to 336ef97 Compare October 12, 2023 07:37
Base automatically changed from dp/admin-api-permissions to main October 12, 2023 07:39
@DafyddLlyr DafyddLlyr force-pushed the dp/use-api-client-for-useHasuraAuth branch from 336ef97 to 2717e01 Compare October 12, 2023 08:26
@theopensystemslab theopensystemslab deleted a comment from github-actions bot Oct 12, 2023
@github-actions
Copy link

github-actions bot commented Oct 12, 2023

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr changed the title feat: Use $api client for request from Hasura → API feat: Use $api client for requests from Hasura → API Oct 12, 2023
*/
export const $admin = new CoreDomainClient({
auth: { adminSecret: process.env.HASURA_GRAPHQL_ADMIN_SECRET! },
export const $api = new CoreDomainClient({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally thrilled with the name of this at it feels a little unspecific, but it follows the existing pattern of $<ROLE> being the client for that role.

We could rename getClient() -> getUserClient() which returns a $user, but similarly this feels a little unclear as you could end up with $user.user.addUser(newUser) 🫠

@DafyddLlyr DafyddLlyr requested a review from a team October 13, 2023 07:20
@DafyddLlyr DafyddLlyr marked this pull request as ready for review October 13, 2023 07:20
@DafyddLlyr DafyddLlyr merged commit 4c65722 into main Oct 13, 2023
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/use-api-client-for-useHasuraAuth branch October 13, 2023 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants