From df26cc05cc291cb58cbcb8f00436d1ca0223b97d Mon Sep 17 00:00:00 2001 From: Tim Griesser Date: Thu, 8 Jun 2017 12:34:35 -0400 Subject: [PATCH] Support graphql ListType (#2061) --- src/printer-graphql.js | 8 +++++++ .../__snapshots__/jsfmt.spec.js.snap | 21 +++++++++++++++++++ .../variable_definitions.graphql | 8 +++++++ 3 files changed, 37 insertions(+) diff --git a/src/printer-graphql.js b/src/printer-graphql.js index ec20e139..e72b032d 100644 --- a/src/printer-graphql.js +++ b/src/printer-graphql.js @@ -250,6 +250,14 @@ function genericPrint(path, options, print) { ]); } + case "ListType": { + return concat([ + "[", + path.call(print, "type"), + "]" + ]) + } + default: throw new Error("unknown graphql type: " + JSON.stringify(n.kind)); } diff --git a/tests/graphql_variable_definitions/__snapshots__/jsfmt.spec.js.snap b/tests/graphql_variable_definitions/__snapshots__/jsfmt.spec.js.snap index 2eeca172..13aeea6e 100644 --- a/tests/graphql_variable_definitions/__snapshots__/jsfmt.spec.js.snap +++ b/tests/graphql_variable_definitions/__snapshots__/jsfmt.spec.js.snap @@ -10,6 +10,14 @@ $bar: String = "Long string here", $arg: String = "Hello world!",,,,, $nonNull: String!) { hello } + +query lists($foo: [Int ], $bar: [Int!], $arg: [ Int! ]!) { + ok +} + +query listslong($foo: [String ], $bar: [String!], $arg: [ Int! ]!, $veryLongName: [ Int! ]) { + ok +} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ query short($foo: ComplexType, $site: Site = MOBILE, $nonNull: Int!) { hello @@ -24,4 +32,17 @@ query long( ) { hello } + +query lists($foo: [Int], $bar: [Int!], $arg: [Int!]!) { + ok +} + +query listslong( + $foo: [String], + $bar: [String!], + $arg: [Int!]!, + $veryLongName: [Int!] +) { + ok +} `; diff --git a/tests/graphql_variable_definitions/variable_definitions.graphql b/tests/graphql_variable_definitions/variable_definitions.graphql index 8c12db83..85e42277 100644 --- a/tests/graphql_variable_definitions/variable_definitions.graphql +++ b/tests/graphql_variable_definitions/variable_definitions.graphql @@ -7,3 +7,11 @@ $bar: String = "Long string here", $arg: String = "Hello world!",,,,, $nonNull: String!) { hello } + +query lists($foo: [Int ], $bar: [Int!], $arg: [ Int! ]!) { + ok +} + +query listslong($foo: [String ], $bar: [String!], $arg: [ Int! ]!, $veryLongName: [ Int! ]) { + ok +}