GraphQL: Implement DirectiveDefinition (#2309)
parent
fbf4c3a952
commit
51c7503dae
|
@ -236,6 +236,43 @@ function genericPrint(path, options, print) {
|
|||
return concat([path.call(print, "name"), ": ", path.call(print, "type")]);
|
||||
}
|
||||
|
||||
case "DirectiveDefinition": {
|
||||
return concat([
|
||||
"directive ",
|
||||
"@",
|
||||
path.call(print, "name"),
|
||||
n.arguments.length > 0
|
||||
? group(
|
||||
concat([
|
||||
"(",
|
||||
indent(
|
||||
concat([
|
||||
softline,
|
||||
join(
|
||||
concat([ifBreak("", ", "), softline]),
|
||||
path.map(print, "arguments")
|
||||
)
|
||||
])
|
||||
),
|
||||
softline,
|
||||
")"
|
||||
])
|
||||
)
|
||||
: "",
|
||||
concat([" on ", join(", ", path.map(print, "locations"))])
|
||||
]);
|
||||
}
|
||||
|
||||
case "InputValueDefinition": {
|
||||
return concat([
|
||||
path.call(print, "name"),
|
||||
": ",
|
||||
path.call(print, "type"),
|
||||
n.defaultValue ? concat([" = ", path.call(print, "defaultValue")]) : "",
|
||||
printDirectives(path, print, n)
|
||||
]);
|
||||
}
|
||||
|
||||
case "FragmentSpread": {
|
||||
return concat([
|
||||
"...",
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`directive_decl.graphql 1`] = `
|
||||
directive @a on FIELD1
|
||||
directive @a(as: String) on FIELD1
|
||||
directive @a(as: String = 1) on FIELD1
|
||||
directive @a(as: String, b: Int!) on FIELD1
|
||||
directive @a(as: String! = 1 @deprecated) on FIELD1
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
directive @a on FIELD1
|
||||
|
||||
directive @a(as: String) on FIELD1
|
||||
|
||||
directive @a(as: String = 1) on FIELD1
|
||||
|
||||
directive @a(as: String, b: Int!) on FIELD1
|
||||
|
||||
directive @a(as: String! = 1 @deprecated) on FIELD1
|
||||
|
||||
`;
|
|
@ -0,0 +1,5 @@
|
|||
directive @a on FIELD1
|
||||
directive @a(as: String) on FIELD1
|
||||
directive @a(as: String = 1) on FIELD1
|
||||
directive @a(as: String, b: Int!) on FIELD1
|
||||
directive @a(as: String! = 1 @deprecated) on FIELD1
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "graphql" });
|
Loading…
Reference in New Issue