diff --git a/src/printer-graphql.js b/src/printer-graphql.js index 838062fad..a43f0c726 100644 --- a/src/printer-graphql.js +++ b/src/printer-graphql.js @@ -214,12 +214,19 @@ function genericPrint(path, options, print) { } case "ObjectTypeDefinition": { - const parent = path.getParentNode(); return concat([ "type ", path.call(print, "name"), + n.interfaces && n.interfaces.length > 0 + ? concat([" implements ", join(", ", path.map(print, "interfaces"))]) + : "", + printDirectives(path, print, n), " {", - indent(concat([hardline, join(hardline, path.map(print, "fields"))])), + n.fields && n.fields.length > 0 + ? indent( + concat([hardline, join(hardline, path.map(print, "fields"))]) + ) + : "", hardline, "}" ]); diff --git a/tests/graphql_object_type_def/__snapshots__/jsfmt.spec.js.snap b/tests/graphql_object_type_def/__snapshots__/jsfmt.spec.js.snap index 048bc3eaf..14a33e43c 100644 --- a/tests/graphql_object_type_def/__snapshots__/jsfmt.spec.js.snap +++ b/tests/graphql_object_type_def/__snapshots__/jsfmt.spec.js.snap @@ -11,6 +11,15 @@ extend type Feedback { `; +exports[`implements.graphql 1`] = ` +type VRMConversation implements Node, Entity @foo { +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +type VRMConversation implements Node, Entity @foo { +} + +`; + exports[`object_type_def.graphql 1`] = ` type FeedHomeStories { debug_info: String diff --git a/tests/graphql_object_type_def/implements.graphql b/tests/graphql_object_type_def/implements.graphql new file mode 100644 index 000000000..62e65f891 --- /dev/null +++ b/tests/graphql_object_type_def/implements.graphql @@ -0,0 +1,2 @@ +type VRMConversation implements Node, Entity @foo { +}