Skip to content

Commit

Permalink
roundtrip test on github
Browse files Browse the repository at this point in the history
  • Loading branch information
obmarg committed May 18, 2024
1 parent e952085 commit 7a91d95
Show file tree
Hide file tree
Showing 9 changed files with 687 additions and 222 deletions.
4 changes: 0 additions & 4 deletions cynic-parser/src/printing/type_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,3 @@ impl<'a> Pretty<'a, Allocator<'a>> for NodeDisplay<StringLiteral<'a>> {
}
}
}

fn comma_or_newline<'a>(allocator: &'a Allocator<'a>) -> pretty::DocBuilder<'a, Allocator<'a>> {
allocator.line().flat_alt(allocator.text(", "))
}
2 changes: 1 addition & 1 deletion cynic-parser/src/printing/type_system/argument_sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::iter::Enumerate;

use pretty::{DocAllocator, Pretty};

use super::{comma_or_newline, Allocator, InputValueDefinition, NodeDisplay};
use super::{Allocator, InputValueDefinition, NodeDisplay};

/// A sequence of things with docstrings attached.
///
Expand Down
10 changes: 10 additions & 0 deletions cynic-parser/tests/actual_schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ macro_rules! schema_tests {
insta::assert_snapshot!(parsed.to_sdl());
}

#[test]
fn roundtrip() {
let parsed = cynic_parser::parse_type_system_document(SCHEMA)
.map_err(|error| error.to_report(SCHEMA))
.unwrap();
let sdl = parsed.to_sdl();

assert_eq!(SCHEMA, sdl);
}

#[test]
fn double_roundtrip() {
let parsed = cynic_parser::parse_type_system_document(SCHEMA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ schema {
subscription: SubscriptionRoot
}

"""
Directs the executor to query only when the field exists.
"""
directive @ifdef on FIELD

type Book {
Expand Down
4 changes: 3 additions & 1 deletion schemas/books.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ schema {
subscription: SubscriptionRoot
}

# Directs the executor to query only when the field exists.
"""
Directs the executor to query only when the field exists.
"""
directive @ifdef on FIELD

type Book {
Expand Down
Loading

0 comments on commit 7a91d95

Please sign in to comment.