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

fix(web): add generation of missing GraphQL queries #1369

Closed
wants to merge 3 commits into from

Conversation

nourbalaha
Copy link
Contributor

@nourbalaha nourbalaha commented Jan 24, 2025

Overview

This PR addresses the issue of missing GraphQL queries by generating them to ensure the application functions as expected.

Summary by CodeRabbit

  • New Features

    • Added optional content encoding for assets
    • Made thread associations in items more flexible
  • Improvements

    • Enhanced GraphQL schema to support more dynamic asset and item configurations

Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Walkthrough

The pull request introduces modifications to the GraphQL schema in the graphql-client-api.tsx and graphql.schema.json files. The primary changes include adding an optional contentEncoding field to Asset and AssetFile types, and making thread and threadId optional in the Item type. These updates enhance the flexibility of the API by allowing more nuanced content encoding specification and providing more lenient thread associations for items.

Changes

File Change Summary
web/src/gql/graphql-client-api.tsx - Added optional contentEncoding to Asset, AssetFile, CreateAssetInput, and CreateAssetUploadInput types
- Made thread and threadId optional in Item type
- Updated GetItemsQuery and GetItemQuery to reflect new type definitions
web/src/gql/graphql.schema.json - Added contentEncoding field to Asset and AssetFile types
- Added contentEncoding to CreateAssetInput and CreateAssetUploadInput input types

Suggested labels

web

Poem

🐰 Hop, hop, through the GraphQL grove,
Where types dance and schemas evolve,
Optional threads, encoding so light,
Flexibility blooms with pure delight!
A rabbit's code, nimble and free, 🌈
Embracing change with glee! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 723c233 and e4b47fe.

📒 Files selected for processing (2)
  • web/src/gql/graphql-client-api.tsx (8 hunks)
  • web/src/gql/graphql.schema.json (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Redirect rules - reearth-cms
  • GitHub Check: Header rules - reearth-cms
  • GitHub Check: Pages changed - reearth-cms
  • GitHub Check: ci-web / ci
🔇 Additional comments (12)
web/src/gql/graphql-client-api.tsx (8)

72-72: Addition of contentEncoding field to Asset type

The contentEncoding field has been added as an optional string field to the Asset type. This is a good addition that allows specifying the encoding format of assets.


106-106: Addition of contentEncoding field to AssetFile type

The contentEncoding field has been added as an optional string field to the AssetFile type, maintaining consistency with the Asset type.


236-236: Addition of contentEncoding field to CreateAssetInput

The contentEncoding field has been added as an optional input field to CreateAssetInput. This allows clients to specify the content encoding when creating new assets.


250-250: Addition of contentEncoding field to CreateAssetUploadInput

The contentEncoding field has been added as an optional input field to CreateAssetUploadInput. This maintains consistency with the CreateAssetInput type.


259-259: Addition of contentEncoding field to CreateAssetUploadPayload

The contentEncoding field has been added as an optional output field to CreateAssetUploadPayload. This allows returning the content encoding information after asset upload.


Line range hint 2555-2577: Updated GetItems and GetItem queries to handle optional thread fields

The GetItemsQuery and GetItemQuery have been updated to handle the optional thread fields correctly. The queries now properly handle the nullable thread and threadId fields.


Line range hint 1-2577: Verify GraphQL schema consistency

Let's verify that all the new contentEncoding fields are consistently defined across the schema and that there are no missing or inconsistent field definitions.

✅ Verification successful

contentEncoding field is consistently defined across the schema

The contentEncoding field is properly defined as an optional string type across all schema definitions and implementations, including GraphQL schema, YAML schema, TypeScript types, and Go code. The field is correctly present in all relevant types (Asset, AssetFile, CreateAssetUploadPayload) and properly handled in the implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all contentEncoding field definitions to verify consistency
rg -A 1 "contentEncoding.*[:\?]"

Length of output: 5595


617-618: Making thread and threadId optional in Item type

The thread and threadId fields in the Item type have been made optional by adding the Maybe type wrapper. This is a good change that provides more flexibility in item creation and representation.

Let me verify if there are any direct references to these fields that might need to be updated:

✅ Verification successful

Optional thread and threadId fields are safely handled

The codebase already properly handles the optional nature of these fields through optional chaining and null checks. All direct usages of thread and threadId are properly guarded, and no updates to the consuming code are necessary.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct references to thread or threadId that might assume non-null
rg -A 2 "thread\!:" || rg -A 2 "threadId\!:"

Length of output: 213


Script:

#!/bin/bash
# Search for direct references to thread and threadId properties
echo "=== Searching for direct property access ==="
rg -t typescript -t tsx "\.thread[^a-zA-Z]" web/
rg -t typescript -t tsx "\.threadId[^a-zA-Z]" web/

echo -e "\n=== Searching for non-null assertions ==="
rg -t typescript -t tsx "thread!" web/
rg -t typescript -t tsx "threadId!" web/

echo -e "\n=== Searching for type definitions ==="
ast-grep --pattern 'interface $_ {
  $$$
  thread: $_
  $$$
}'

ast-grep --pattern 'interface $_ {
  $$$
  threadId: $_
  $$$
}'

Length of output: 750


Script:

#!/bin/bash
echo "=== Searching for thread/threadId usage ==="
# Search in TypeScript/TSX files
rg "\.(thread|threadId)[^a-zA-Z]" web/src/ -g "*.{ts,tsx}"
rg "(thread|threadId)!" web/src/ -g "*.{ts,tsx}"

# Search in GraphQL files
echo -e "\n=== Searching in GraphQL files ==="
rg "thread" web/src/ -g "*.graphql"
rg "threadId" web/src/ -g "*.graphql"

# Search for type definitions and usage
echo -e "\n=== Searching type definitions ==="
rg "thread.*:.*Thread" web/src/ -g "*.{ts,tsx}"
rg "threadId.*:.*ID" web/src/ -g "*.{ts,tsx}"

Length of output: 40791

web/src/gql/graphql.schema.json (4)

366-377: LGTM! The contentEncoding field is properly added to the Asset type.

The field is correctly defined as an optional String type, which allows for flexible content encoding specification while maintaining backward compatibility.


760-771: LGTM! The contentEncoding field is consistently added to the AssetFile type.

The field definition matches the Asset type, maintaining schema consistency.


1995-2006: LGTM! Content encoding support is properly added to asset creation and upload types.

The contentEncoding field is consistently added to:

  • CreateAssetInput
  • CreateAssetUploadInput
  • CreateAssetUploadPayload

This provides complete support for specifying and retrieving content encoding information throughout the asset lifecycle.

Also applies to: 2111-2122, 2186-2197


5367-5369: LGTM! Thread fields are properly made optional in the Item type.

The thread and threadId fields are correctly made optional by removing the NON_NULL wrapper, allowing items to exist without thread associations.

Also applies to: 5379-5381


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?

❤️ 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. (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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@nourbalaha nourbalaha self-assigned this Jan 24, 2025
@github-actions github-actions bot added the web label Jan 24, 2025
Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for reearth-cms ready!

Name Link
🔨 Latest commit a851124
🔍 Latest deploy log https://app.netlify.com/sites/reearth-cms/deploys/67972711f966120008ca6922
😎 Deploy Preview https://deploy-preview-1369--reearth-cms.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nourbalaha nourbalaha changed the title fix(web): generate missing GQL queries fix(web): add generation of missing GraphQL queries Jan 24, 2025
@nourbalaha nourbalaha closed this Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant