GraphQL: Implement Enum (#2310)
parent
51c7503dae
commit
b63e1c2dd7
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
`;
|
|
@ -0,0 +1,5 @@
|
|||
enum State {
|
||||
PENDING
|
||||
VISIBLE
|
||||
ARCHIVED
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "graphql" });
|
Loading…
Reference in New Issue