Skip to content

feat: add manual relationship in hasura #87

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

0xnigir1
Copy link
Collaborator

@0xnigir1 0xnigir1 commented Mar 5, 2025

Description

We need to add a manual relationship for Applications -> Projects, that emulates a many-to-many on 'projectId' (we have a Foreign key but is a One-to-Many on projectId+chainId)

This allows us to make queries like:

query ApplicationsByCanonicalProject {
  applications {
    id
    chainId
    projects(where: {projectType: {_eq: "canonical"}}) {
      projectType
      id
      name
    }
  }
}

where we get the Canonical project/s for an Application
image

Summary by CodeRabbit

  • New Features
    • Enhanced data integration by linking project details with application records, providing a more seamless management experience.

@0xnigir1 0xnigir1 self-assigned this Mar 5, 2025
Copy link

coderabbitai bot commented Mar 5, 2025

📝 Walkthrough

Walkthrough

A new relationship entry has been introduced in the configuration script for Hasura. The update adds an item to the virtualArrayRelationships array in the scripts/hasura-config/src/index.ts file. This entry establishes a relationship named "projects" that links the "applications" table to a remote "projects" table. The configuration explicitly defines the source as "default" and provides a manual setup, including a column mapping where project_id from the remote table corresponds to id in the local table. The remote table is specified with the name "projects" and uses the "public" schema.


📜 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 f59727c and 6545984.

📒 Files selected for processing (1)
  • scripts/hasura-config/src/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.ts`:

**/*.ts:

  • scripts/hasura-config/src/index.ts
`scripts/**/*.ts`: Ensure scripts: - Use `process.cwd()` f...

scripts/**/*.ts: Ensure scripts:

  • Use process.cwd() for root references.
  • Follow folder conventions (infra/ for infra scripts, utilities/ for utilities).
  • Are organized in package.json with script:infra:{name} or script:util:{name}.
  • Be concise and avoid overly nitpicky feedback outside of these best practices.
  • scripts/hasura-config/src/index.ts
🔇 Additional comments (1)
scripts/hasura-config/src/index.ts (1)

90-109: Well-implemented relationship for applications to projects.

The new relationship entry has been correctly implemented following the existing patterns in the codebase. This manual relationship configuration properly connects applications to projects based on the project_id field, which allows for the many-to-many relationship described in the PR objectives.

The implementation will enable the complex queries mentioned in the PR description, such as retrieving canonical projects associated with applications, by allowing GraphQL queries to traverse from applications to their related projects.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
  • @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.

using: {
manual_configuration: {
remote_table: {
name: "projects",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've got no idea about the Hasura syntax lol but is this ok? Using the same remote table name here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah this is ok

@0xnigir1 0xnigir1 merged commit 1469d64 into dev Mar 5, 2025
7 checks passed
@0xnigir1 0xnigir1 deleted the feat/add-application-project-array-rel branch March 5, 2025 16:45
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.

4 participants