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

Use block string syntax in serialization #664

Closed
dariuszkuc opened this issue Sep 27, 2023 · 1 comment · Fixed by #724
Closed

Use block string syntax in serialization #664

dariuszkuc opened this issue Sep 27, 2023 · 1 comment · Fixed by #724
Assignees
Labels
apollo-compiler issues/PRs pertaining to semantic analysis & validation bug Something isn't working

Comments

@dariuszkuc
Copy link
Member

Description

GraphQL supports both single line (wrapped in ") and multiline comments (wrapped in """). apollo-rs currently does not support multiline comments and coalesce it to a single line, i.e.

"""
First line comment
Second line comment
"""

becomes

"First line comment\nSecond line comment"

Steps to reproduce

#[test]
    fn comments() {
        let raw_comment = r#""""
First Line
Second Line
""""#;
        let multiline_comment = "First Line
Second Line";

        let foo = ObjectType {
            name: Name::new("foo"),
            description: Some(NodeStr::new(multiline_comment)),
            directives: vec![],
            fields: IndexMap::new(),
            implements_interfaces: IndexMap::new(),
        };

        let mut schema = Schema::new();
        schema
            .types
            .insert(Name::new("foo"), ExtendedType::Object(Node::new(foo)));
        println!("{}", schema);
    }

Expected result

Printed descriptions should preserve multiline comments.

Actual result

When using raw_string (from above) prints following schema

"\"\"\"\nFirst Line\nSecond Line\n\"\"\""
type foo

When using multiline_comment (from above) prints following schema

"First Line\nSecond Line"
type foo

Environment

  • Operating system and version: MacOS Ventura
  • Shell (bash/zsh/powershell): zsh
  • apollo-rs crate: mut branch
  • Crate version: 1.72.0
@dariuszkuc dariuszkuc added bug Something isn't working triage labels Sep 27, 2023
@SimonSapin SimonSapin added apollo-compiler issues/PRs pertaining to semantic analysis & validation and removed triage labels Oct 6, 2023
@SimonSapin SimonSapin changed the title schema printer does not support multiline comments Use block string syntax in serialization Oct 19, 2023
@SimonSapin SimonSapin self-assigned this Nov 6, 2023
SimonSapin added a commit that referenced this issue Nov 6, 2023
@SimonSapin
Copy link
Contributor

Implementation PR: #724

See also stylistic question: #724 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apollo-compiler issues/PRs pertaining to semantic analysis & validation bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants