Add alias and null value (#2017)

Add kitchen sink test case
master
Sashko Stubailo 2017-06-06 18:06:15 -07:00 committed by Christopher Chedeau
parent 1f3665fba0
commit 0583fd4ce6
4 changed files with 172 additions and 0 deletions

View File

@ -74,6 +74,7 @@ function genericPrint(path, options, print) {
case "Field": {
return group(
concat([
n.alias ? concat([path.call(print, "alias"), ": "]) : "",
path.call(print, "name"),
n.arguments.length > 0
? group(
@ -113,6 +114,9 @@ function genericPrint(path, options, print) {
case "BooleanValue": {
return n.value ? "true" : "false";
}
case "NullValue": {
return "null";
}
case "Variable": {
return concat(["$", path.call(print, "name")]);
}

View File

@ -0,0 +1,113 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`kitchen_sink.graphql 1`] = `
query queryName($foo: ComplexType, $site: Site = MOBILE) {
whoever123is: node(id: [123, 456]) {
id ,
... on User @defer {
field2 {
id ,
alias: field1(first:10, after:$foo,) @include(if: $foo) {
id,
...frag
}
}
}
... @skip(unless: $foo) {
id
}
... {
id
}
}
}
mutation likeStory {
like(story: 123) @defer {
story {
id
}
}
}
subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
storyLikeSubscribe(input: $input) {
story {
likers {
count
}
likeSentence {
text
}
}
}
}
fragment frag on Friend {
foo(size: $size, bar: $b, obj: {key: "value"})
}
{
unnamed(truthy: true, falsey: false, nullish: null),
query
}
query {
field
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
query queryName($foo: ComplexType, $site: Site = MOBILE) {
whoever123is: node(id: [123, 456]) {
id
... on User @defer {
field2 {
id
alias: field1(first: 10, after: $foo) @include(if: $foo) {
id
...frag
}
}
}
... @skip(unless: $foo) {
id
}
... {
id
}
}
}
mutation likeStory {
like(story: 123) @defer {
story {
id
}
}
}
subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
storyLikeSubscribe(input: $input) {
story {
likers {
count
}
likeSentence {
text
}
}
}
}
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value" })
}
{
unnamed(truthy: true, falsey: false, nullish: null)
query
}
query {
field
}
`;

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "graphql" });

View File

@ -0,0 +1,54 @@
query queryName($foo: ComplexType, $site: Site = MOBILE) {
whoever123is: node(id: [123, 456]) {
id ,
... on User @defer {
field2 {
id ,
alias: field1(first:10, after:$foo,) @include(if: $foo) {
id,
...frag
}
}
}
... @skip(unless: $foo) {
id
}
... {
id
}
}
}
mutation likeStory {
like(story: 123) @defer {
story {
id
}
}
}
subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
storyLikeSubscribe(input: $input) {
story {
likers {
count
}
likeSentence {
text
}
}
}
}
fragment frag on Friend {
foo(size: $size, bar: $b, obj: {key: "value"})
}
{
unnamed(truthy: true, falsey: false, nullish: null),
query
}
query {
field
}