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: input types loose out on provided graphQL documentation #1657

Closed
wants to merge 3 commits into from

Conversation

sn99
Copy link

@sn99 sn99 commented Apr 4, 2024

Summary:
Add descriptions to input object types

Issue Reference(s):
Fixes #1625

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

/claim #1625

Summary by CodeRabbit

  • New Features
    • Enhanced parsing capabilities for SDL descriptions, improving the creation of types with documentation and fields.
  • Tests
    • Added a new test for verifying the improved parsing functionality of SDL descriptions.

Copy link
Contributor

coderabbitai bot commented Apr 4, 2024

Walkthrough

The changes introduced aim to enhance the handling of input types and documentation within the GraphQL schema generation process. This includes the addition of a new test to verify the parsing of SDL descriptions into the config structure, as well as modifications to improve the handling of input object types and the inclusion of documentation in the generated schema.

Changes

File(s) Change Summary
src/config/config.rs Added test_from_sdl_description() to verify SDL description parsing.
src/config/from_document.rs Enhanced handling of input object types and documentation inclusion.

Assessment against linked issues

Objective Addressed Explanation
Copy the documentation into the blueprint for input types (#1625)
Ensure integration tests are added for documentation copying (#1625)
Optional fields in input types marked as required (#1212) It's unclear if the modifications to input object handling address this without specific mention of optional field handling.
Correctly handle wrapper types for vec outputs (#1212) The changes mention improvements in handling input objects, but it's not clear if this extends to wrapper types for vec outputs.
Generate enum fields in types with a mix of scalar and enum fields (#1212) There's no direct mention of enhancements in enum field generation within the provided summaries.

Possibly related issues


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@github-actions github-actions bot added type: docs Related to documentation and information. type: fix Iterations on existing features or infrastructure. labels Apr 4, 2024
Comment on lines +838 to +863

#[test]
fn test_from_sdl_description() {
let actual = Config::from_sdl(
r#"
"""
Some Documentation
"""
input Foo {
id: Int!
}
"#,
)
.to_result()
.unwrap();

let expected = Config::default().types(vec![(
"Foo",
Type {
doc: Some("Some Documentation".to_string()),
..Default::default()
}
.fields(vec![("id", Field::int().required(true))]),
)]);
assert_eq!(actual, expected);
}
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 4, 2024

Choose a reason for hiding this comment

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

Add assertions for the fields and scalar properties in the test_from_sdl_description test to ensure comprehensive coverage.

#[test]
fn test_from_sdl_description() {
    // Test setup and execution...
    assert_eq!(actual.types["Foo"].fields["id"].type_of, "Int");
    assert!(!actual.types["Foo"].scalar);
}

This enhancement will verify that the input object type Foo not only has the correct documentation but also accurately reflects its fields and scalar property, ensuring a more thorough test coverage.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can drop this test and add one like this https://github.com/tailcallhq/tailcall/tree/main/tests/execution

Copy link
Contributor

Choose a reason for hiding this comment

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

@tusharmath, based on your request to drop the existing test and add a new one similar to those in the tests/execution directory, here's a proposed approach:

  1. Remove the existing test: The existing test_from_sdl_description test in src/config/config.rs will be removed as per your instruction.

  2. Add a new test: A new test will be added following the structure and style observed in the tests/execution directory. The provided output from the tests/execution directory suggests a pattern of testing involving server configurations, mock requests, and assertions. However, since the task is to modify a Rust test file, and the provided examples are not directly applicable to Rust code, I'll generate a Rust test that conceptually aligns with the pattern of setting up a scenario, executing a function, and asserting the outcome.

Here's a conceptual Rust test that aligns with the instructions:

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_new_sdl_description_behavior() {
        // Setup the test environment
        let sdl = r#"
            """
            Example Documentation
            """
            input ExampleInput {
                id: Int!
            }
        "#;

        // Execute the function under test
        let config = Config::from_sdl(sdl).to_result().unwrap();

        // Assert the expected outcome
        assert_eq!(config.types["ExampleInput"].doc, Some("Example Documentation".to_string()));
        assert_eq!(config.types["ExampleInput"].fields["id"].type_of, "Int");
        assert!(config.types["ExampleInput"].fields["id"].required);
    }
}

This test checks that the SDL description is correctly parsed and associated with the ExampleInput type, and that the id field is correctly identified as an Int and marked as required. This aligns with the objective of ensuring that descriptions for input object types are correctly parsed and included in the generated schema, as well as verifying the field types and requirements.

Please review this approach and let me know if it meets your expectations or if further adjustments are needed.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# List the files in the tests/execution directory to choose a representative file.
fd . tests/execution --exec cat {}

Length of output: 180053

Copy link
Author

Choose a reason for hiding this comment

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

@tusharmath I am having trouble with what the test will look like, can you give me a hint?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor

Choose a reason for hiding this comment

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

Check out this test — tests/execution/test-query-documentation.md

Copy link
Author

Choose a reason for hiding this comment

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

@tusharmath does the test look alright?

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.13%. Comparing base (4654c0e) to head (fc7223b).
Report is 69 commits behind head on main.

❗ Current head fc7223b differs from pull request most recent head 1a5a548. Consider uploading reports for the commit 1a5a548 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1657      +/-   ##
==========================================
+ Coverage   87.10%   87.13%   +0.02%     
==========================================
  Files         148      148              
  Lines       15145    15178      +33     
==========================================
+ Hits        13192    13225      +33     
  Misses       1953     1953              

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

@tusharmath tusharmath marked this pull request as draft April 7, 2024 11:09
Copy link

github-actions bot commented Apr 9, 2024

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels Apr 9, 2024
Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels Apr 12, 2024
Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels Apr 14, 2024
Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels Apr 16, 2024
Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels Apr 18, 2024
Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Apr 20, 2024
Copy link

PR closed after 5 days of inactivity.

@github-actions github-actions bot closed this Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Bounty claim state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. type: docs Related to documentation and information. type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(config): input types loose out on provided graphQL documentation
2 participants