graphql: Allow interfaces to implement other interfaces (#8007)

* `graphql`: Allow interfaces to implement other interfaces

* Add changelog
This commit is contained in:
fisker Cheung authored and GitHub committed 2020-04-10 20:27:25 +08:00
1 parent 7e8b6b7617
commit cf6f251b3c
4 files changed
+141 -1

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
#### Allow interfaces to implement other interfaces ([#8007](https://github.com/prettier/prettier/pull/8007) by [@fisker](https://github.com/fisker))
See ["RFC: Allow interfaces to implement other interfaces"](https://github.com/graphql/graphql-spec/pull/373)
<!-- prettier-ignore -->
```graphql
# Input
interface Resource implements Node {
id: ID!
url: String
}
# Prettier stable
interface Resource {
id: ID!
url: String
}
# Prettier master
interface Resource implements Node {
id: ID!
url: String
}
```
+6 -1
View File
@@ -506,8 +506,13 @@ function genericPrint(path, options, print) {
n.kind === "InterfaceTypeExtension" ? "extend " : "",
"interface ",
path.call(print, "name"),
n.interfaces.length > 0
? concat([
" implements ",
concat(printInterfaces(path, options, print)),
])
: "",
printDirectives(path, print, n),
n.fields.length > 0
? concat([
" {",
@@ -6,17 +6,89 @@ parsers: ["graphql"]
printWidth: 80
| printWidth
=====================================input======================================
# https://github.com/graphql/graphql-spec/blob/master/spec/Section%203%20--%20Type%20System.md#interfaces
interface Actor {
id: ID
name: String
}
interface Resource implements Node
{
id: ID!
url: String
}
interface Resource implements
Node {
id: ID!
url: String
}
interface Image implements Resource
& Node {
id: ID!
url: String
thumbnail: String
}
interface Node implements Named &
Node {
id: ID!
name: String
}
interface Named implements
Node & Named {
id: ID!
name: String
}
# \`InterfaceTypeExtension\`
extend interface Bar implements
A, B & C {
two(argument: InputType!): Type
}
=====================================output=====================================
# https://github.com/graphql/graphql-spec/blob/master/spec/Section%203%20--%20Type%20System.md#interfaces
interface Actor {
id: ID
name: String
}
interface Resource implements Node {
id: ID!
url: String
}
interface Resource implements Node {
id: ID!
url: String
}
interface Image implements Resource & Node {
id: ID!
url: String
thumbnail: String
}
interface Node implements Named & Node {
id: ID!
name: String
}
interface Named implements Node & Named {
id: ID!
name: String
}
# \`InterfaceTypeExtension\`
extend interface Bar implements A, B & C {
two(argument: InputType!): Type
}
================================================================================
`;
+39
View File
@@ -1,4 +1,43 @@
# https://github.com/graphql/graphql-spec/blob/master/spec/Section%203%20--%20Type%20System.md#interfaces
interface Actor {
id: ID
name: String
}
interface Resource implements Node
{
id: ID!
url: String
}
interface Resource implements
Node {
id: ID!
url: String
}
interface Image implements Resource
& Node {
id: ID!
url: String
thumbnail: String
}
interface Node implements Named &
Node {
id: ID!
name: String
}
interface Named implements
Node & Named {
id: ID!
name: String
}
# `InterfaceTypeExtension`
extend interface Bar implements
A, B & C {
two(argument: InputType!): Type
}