From bbf8f76823fc8b3a577409a743c15f7dd97dc62e Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 27 Jun 2017 19:34:25 -0700 Subject: [PATCH] GraphQL: Implement scalar (#2313) --- src/printer-graphql.js | 8 ++++++++ tests/graphql_scalar/__snapshots__/jsfmt.spec.js.snap | 8 ++++++++ tests/graphql_scalar/jsfmt.spec.js | 1 + tests/graphql_scalar/scalar.graphql | 1 + 4 files changed, 18 insertions(+) create mode 100644 tests/graphql_scalar/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/graphql_scalar/jsfmt.spec.js create mode 100644 tests/graphql_scalar/scalar.graphql diff --git a/src/printer-graphql.js b/src/printer-graphql.js index c7308bf2..999a55af 100644 --- a/src/printer-graphql.js +++ b/src/printer-graphql.js @@ -365,6 +365,14 @@ function genericPrint(path, options, print) { ); } + case "ScalarTypeDefinition": { + return concat([ + "scalar ", + path.call(print, "name"), + printDirectives(path, print, n) + ]); + } + case "NonNullType": { return concat([path.call(print, "type"), "!"]); } diff --git a/tests/graphql_scalar/__snapshots__/jsfmt.spec.js.snap b/tests/graphql_scalar/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..47237c30 --- /dev/null +++ b/tests/graphql_scalar/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`scalar.graphql 1`] = ` +scalar Color @deprecated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +scalar Color @deprecated + +`; diff --git a/tests/graphql_scalar/jsfmt.spec.js b/tests/graphql_scalar/jsfmt.spec.js new file mode 100644 index 00000000..335646fb --- /dev/null +++ b/tests/graphql_scalar/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "graphql" }); diff --git a/tests/graphql_scalar/scalar.graphql b/tests/graphql_scalar/scalar.graphql new file mode 100644 index 00000000..e999eb8c --- /dev/null +++ b/tests/graphql_scalar/scalar.graphql @@ -0,0 +1 @@ +scalar Color @deprecated