GraphQL: Implement Enum (#2310)

master
Christopher Chedeau 2017-06-27 19:20:53 -07:00 committed by GitHub
parent 51c7503dae
commit b63e1c2dd7
4 changed files with 47 additions and 2 deletions

View File

@ -217,12 +217,12 @@ function genericPrint(path, options, print) {
return concat([
"type ",
path.call(print, "name"),
n.interfaces && n.interfaces.length > 0
n.interfaces.length > 0
? concat([" implements ", join(", ", path.map(print, "interfaces"))])
: "",
printDirectives(path, print, n),
" {",
n.fields && n.fields.length > 0
n.fields.length > 0
? indent(
concat([hardline, join(hardline, path.map(print, "fields"))])
)
@ -263,6 +263,29 @@ function genericPrint(path, options, print) {
]);
}
case "EnumTypeDefinition": {
return concat([
"enum ",
path.call(print, "name"),
printDirectives(path, print, n),
" {",
n.values.length > 0
? indent(
concat([hardline, join(hardline, path.map(print, "values"))])
)
: "",
hardline,
"}"
]);
}
case "EnumValueDefinition": {
return concat([
path.call(print, "name"),
printDirectives(path, print, n)
]);
}
case "InputValueDefinition": {
return concat([
path.call(print, "name"),

View File

@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`enum.graphql 1`] = `
enum State {
PENDING
VISIBLE
ARCHIVED
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
enum State {
PENDING
VISIBLE
ARCHIVED
}
`;

View File

@ -0,0 +1,5 @@
enum State {
PENDING
VISIBLE
ARCHIVED
}

View File

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