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

refactor(torii-gql): get rid of world indexing error #2827

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

Larkooo
Copy link
Collaborator

@Larkooo Larkooo commented Dec 20, 2024

Fixes #2811.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Simplified GraphQL response handling by removing unnecessary parameters and functions.
  • Bug Fixes

    • Improved control flow for GraphQL responses by eliminating checks for empty models.

Copy link

coderabbitai bot commented Dec 20, 2024

Walkthrough

Ohayo, sensei! The changes simplify the GraphQL server configuration in the Torii crate. The modifications remove the logic for handling empty model states by eliminating the is_empty parameter from the graphql_filter function and removing the empty_response function. The new function no longer acquires a database connection or counts models, streamlining the server initialization process.

Changes

File Change Summary
crates/torii/graphql/src/server.rs - Removed is_empty parameter from graphql_filter function
- Deleted empty_response() function
- Simplified new() function to directly call graphql_filter(schema)

Assessment against linked issues

Objective Addressed Explanation
Ensure indexing error message is consistently returned when data is not fully indexed (#2811) The changes do not address the issue of the error message disappearing when data is not fully indexed.

Possibly Related PRs

Suggested Reviewers

  • steebchen

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 636f864 and 593a416.

📒 Files selected for processing (1)
  • crates/torii/graphql/src/server.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/torii/graphql/src/server.rs

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/torii/graphql/src/server.rs (1)

22-22: Ohayo! Consider adding health checks for database state

While simplifying the initialization is good for performance, we might want to ensure the GraphQL server can properly handle database connectivity issues.

Consider adding a separate health check endpoint that validates database connectivity and model state, rather than doing it during initialization. This would provide better observability without blocking server startup.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0b8033 and 636f864.

📒 Files selected for processing (1)
  • crates/torii/graphql/src/server.rs (1 hunks)
🔇 Additional comments (2)
crates/torii/graphql/src/server.rs (2)

28-29: Ohayo sensei! Clean function signature simplification

The removal of the is_empty parameter makes the code more maintainable and follows the principle of single responsibility.


Line range hint 30-36: Verify error handling for empty world states

With the removal of empty state handling, we should verify that GraphQL queries properly handle cases where no world data exists.

✅ Verification successful

Ohayo sensei! After analyzing the codebase, I can now provide a definitive response about the empty world state handling.

GraphQL queries properly handle empty states through built-in error handling and testing

  • The GraphQL server has proper error handling in server.rs where responses are wrapped and returned with their errors
  • Empty state handling is explicitly tested in test_empty_content in metadata_test.rs
  • The codebase includes comprehensive pagination handling for empty results, as seen in entities_test.rs
  • GraphQL responses are checked for errors before processing (assert!(res.errors.is_empty()))

The removal of empty state handling you mentioned appears to be safe since the codebase already has robust error handling and empty state testing in place.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for error handling patterns in GraphQL queries

# Look for error handling patterns in GraphQL schema and resolvers
ast-grep --pattern 'async fn resolve($$$) {
  $$$
  Error($$$)
  $$$
}'

# Check for any existing error handling tests
rg -l "test.*empty.*world" --type rust

Length of output: 114


Script:

#!/bin/bash
# Let's check for error handling patterns in GraphQL resolvers with a broader search
ast-grep --pattern 'async fn resolve($$$) {
    $$$
}'

# Search for error handling in GraphQL-related files
rg -A 5 "Error|error" --type rust crates/torii/graphql/

# Look for test files related to GraphQL
fd "test.*\.rs$" crates/torii/graphql/

# Check for world state handling in GraphQL resolvers
rg -A 5 "world|World" --type rust crates/torii/graphql/

Length of output: 32354


Script:

#!/bin/bash
# Let's check for error handling in GraphQL schema execution
rg -A 5 "schema.execute" crates/torii/graphql/

# Look for error handling in GraphQL response processing
rg -A 5 "response.*errors" crates/torii/graphql/

# Check for any empty state handling in tests
rg -A 5 "empty|None|null" crates/torii/graphql/src/tests/

Length of output: 14176

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 56.30%. Comparing base (c0b8033) to head (593a416).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
crates/torii/graphql/src/server.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2827      +/-   ##
==========================================
+ Coverage   55.92%   56.30%   +0.37%     
==========================================
  Files         439      439              
  Lines       56156    56258     +102     
==========================================
+ Hits        31408    31677     +269     
+ Misses      24748    24581     -167     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

[BUG] Torii is not returning indexing error even though it hasn't fully indexed data
2 participants