Skip to content

Commit

Permalink
Bug: printer can print non-parsable value
Browse files Browse the repository at this point in the history
This fixes a bug where an empty "block" list could be skipped by the printer.

Commit:
ea5b241487c884edb561b12e0a92e947107bbfc1 [ea5b241]
Parents:
ec05b5404b
Author:
Lee Byron <lee@leebyron.com>
Date:
5 May 2016 at 7:26:11 AM SGT
Commit Date:
5 May 2016 at 7:26:13 AM SGT
  • Loading branch information
sogko committed Jun 6, 2016
1 parent 2b3b103 commit b71c906
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions language/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ func wrap(start, maybeString, end string) string {
}
return start + maybeString + end
}

// Given array, print each item on its own line, wrapped in an indented "{ }" block.
func block(maybeArray interface{}) string {
if maybeArray == nil {
return ""
}
s := toSliceString(maybeArray)
if len(s) == 0 {
return "{}"
}
return indent("{\n"+join(s, "\n")) + "\n}"
}

Expand Down
2 changes: 2 additions & 0 deletions language/printer/schema_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ extend type Foo {
seven(argument: [String]): Type
}
type NoFields {}
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
Expand Down
2 changes: 2 additions & 0 deletions schema-kitchen-sink.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ extend type Foo {
seven(argument: [String]): Type
}

type NoFields {}

directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

directive @include(if: Boolean!)
Expand Down

0 comments on commit b71c906

Please sign in to comment.