-
Notifications
You must be signed in to change notification settings - Fork 8
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: add gql user query #355
Conversation
chore: develop -> main
### [4.3.2](v4.3.1...v4.3.2) (2024-05-16) ### Miscellaneous Chores * upgrading cosmjs ([#352](#352)) ([32739a7](32739a7)) [skip ci]
WalkthroughIn version 4.3.2 of the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- CHANGELOG.md (1 hunks)
- package.json (1 hunks)
- src/gql/heart-monitor/heart-monitor.test.ts (2 hunks)
- src/gql/heart-monitor/heart-monitor.ts (3 hunks)
- src/gql/query/index.ts (1 hunks)
- src/gql/query/users.ts (2 hunks)
Files skipped from review due to trivial changes (3)
- CHANGELOG.md
- package.json
- src/gql/query/index.ts
Additional Context Used
Biome (8)
src/gql/heart-monitor/heart-monitor.test.ts (4)
97-101: Prefer for...of instead of forEach.
98-100: Prefer for...of instead of forEach.
996-998: Prefer for...of instead of forEach.
1-94: Some named imports are only used as types.
src/gql/heart-monitor/heart-monitor.ts (3)
106-106: void is not valid as a constituent in a union type
1-2: Some named imports are only used as types.
2-101: Some named imports are only used as types.
src/gql/query/users.ts (1)
1-11: Some named imports are only used as types.
Additional comments not posted (6)
src/gql/query/users.ts (3)
13-15
: TheGqlOutUser
interface is correctly defined and aligns with the GraphQL schema expectations.
20-31
: TheuserQueryString
function is well-implemented. It correctly constructs a GraphQL query string based on the provided arguments and fields.
10-10
: Ensure thatGQLQueryGqlUserArgs
is used appropriately throughout the file since it's a new import.Verification successful
The
GQLQueryGqlUserArgs
type is used appropriately in thesrc/gql/query/users.ts
file and other relevant files, such assrc/gql/heart-monitor/heart-monitor.ts
and its corresponding test file. This confirms that the type is integrated correctly across the project.
src/gql/query/users.ts
: Lines 10, 11, 12src/gql/heart-monitor/heart-monitor.ts
: Lines 10, 11, 12src/gql/heart-monitor/heart-monitor.test.ts
: Lines 10, 11Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `GQLQueryGqlUserArgs` across the project. # Test: Search for the usage of `GQLQueryGqlUserArgs`. Expect: Usage in relevant files. rg --type typescript $'GQLQueryGqlUserArgs'Length of output: 77
Script:
#!/bin/bash # Description: Verify the usage of `GQLQueryGqlUserArgs` across the project. # Test: Search for the usage of `GQLQueryGqlUserArgs`. Expect: Usage in relevant files. rg --type ts 'GQLQueryGqlUserArgs'Length of output: 615
src/gql/heart-monitor/heart-monitor.ts (2)
226-229
: Theuser
function added to theIHeartMonitor
interface is correctly typed and promises to return aGqlOutUser
. This aligns with the GraphQL schema and TypeScript best practices.
372-373
: The implementation of theuser
function in theHeartMonitor
class correctly delegates to the standaloneuser
function, ensuring separation of concerns and reusability.src/gql/heart-monitor/heart-monitor.test.ts (1)
1001-1013
: The test case for theuser
function is comprehensive, covering various fields and ensuring they are present. This helps in maintaining robustness in the GraphQL API's response structure.
export const user = async ( | ||
args: GQLQueryGqlUserArgs, | ||
endpt: string, | ||
fields: DeepPartial<GQLUser> | ||
): Promise<GqlOutUser> => | ||
doGqlQuery(userQueryString(args, false, fields), endpt) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
The doGqlQuery
function implementation does not include explicit error handling. It performs a fetch request and directly returns the cleaned response. To ensure robust error handling, consider adding try-catch blocks and handling potential errors from the fetch request.
- Location:
src/gql/utils/consts.ts
Analysis chain
The user
function is correctly implemented to perform a GraphQL query using the userQueryString
. Ensure that error handling is robust in the doGqlQuery
function.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the error handling in `doGqlQuery` function.
# Test: Search for the implementation of `doGqlQuery`. Expect: Proper error handling.
rg --type typescript $'doGqlQuery'
Length of output: 68
Script:
#!/bin/bash
# Description: Verify the error handling in `doGqlQuery` function.
# Test: Search for the implementation of `doGqlQuery`. Expect: Proper error handling.
rg --type ts 'doGqlQuery'
Length of output: 2565
Script:
#!/bin/bash
# Description: Extract the implementation of `doGqlQuery` function to verify error handling.
# Extract the implementation of `doGqlQuery` from `src/gql/utils/consts.ts`.
rg --type ts --context 10 'export const doGqlQuery' src/gql/utils/consts.ts
Length of output: 675
const testUser = async (args: GQLQueryGqlUserArgs, fields: GQLUser) => { | ||
const resp = await heartMonitor.user(args, fields) | ||
expect(resp).toHaveProperty("user") | ||
|
||
const fieldsToCheck = ["address", "balances", "created_block", "is_blocked"] | ||
fieldsToCheck.forEach((field: string) => { | ||
expect(resp.user).toHaveProperty(field) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The testUser
function is well-implemented, checking for expected properties on the user
object. Consider using a for...of
loop for better readability and performance in future iterations.
- fieldsToCheck.forEach((field: string) => {
- expect(resp.user).toHaveProperty(field)
- })
+ for (const field of fieldsToCheck) {
+ expect(resp.user).toHaveProperty(field)
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const testUser = async (args: GQLQueryGqlUserArgs, fields: GQLUser) => { | |
const resp = await heartMonitor.user(args, fields) | |
expect(resp).toHaveProperty("user") | |
const fieldsToCheck = ["address", "balances", "created_block", "is_blocked"] | |
fieldsToCheck.forEach((field: string) => { | |
expect(resp.user).toHaveProperty(field) | |
}) | |
} | |
const testUser = async (args: GQLQueryGqlUserArgs, fields: GQLUser) => { | |
const resp = await heartMonitor.user(args, fields) | |
expect(resp).toHaveProperty("user") | |
const fieldsToCheck = ["address", "balances", "created_block", "is_blocked"] | |
for (const field of fieldsToCheck) { | |
expect(resp.user).toHaveProperty(field) | |
} | |
} |
Summary by CodeRabbit
New Features
Bug Fixes
Chores
cosmjs
dependency.Tests