From fa112defe8e456a7ee8e19eb9a55579de5820061 Mon Sep 17 00:00:00 2001 From: Juan Manuel Castillo Date: Mon, 25 Oct 2021 14:30:06 +0000 Subject: [PATCH] add interfaces to InterfaceTypeDefinitionNode (https://github.com/gql-dart/gql/issues/269) --- gql/lib/src/ast/ast.dart | 3 +++ gql/lib/src/language/parser.dart | 2 ++ gql/lib/src/language/printer.dart | 1 + 3 files changed, 6 insertions(+) diff --git a/gql/lib/src/ast/ast.dart b/gql/lib/src/ast/ast.dart index a71354e3..c29507e0 100644 --- a/gql/lib/src/ast/ast.dart +++ b/gql/lib/src/ast/ast.dart @@ -811,11 +811,13 @@ class InputValueDefinitionNode extends Node { class InterfaceTypeDefinitionNode extends TypeDefinitionNode { final List fields; + final List interfaces; const InterfaceTypeDefinitionNode({ this.fields = const [], StringValueNode? description, required NameNode name, + this.interfaces = const [], List directives = const [], FileSpan? span, }) : super( @@ -833,6 +835,7 @@ class InterfaceTypeDefinitionNode extends TypeDefinitionNode { name, description, directives, + interfaces, fields, ]; } diff --git a/gql/lib/src/language/parser.dart b/gql/lib/src/language/parser.dart index d4882479..98777079 100644 --- a/gql/lib/src/language/parser.dart +++ b/gql/lib/src/language/parser.dart @@ -740,12 +740,14 @@ class _Parser { final description = _parseDescription(); _expectKeyword("interface"); final name = _parseName("Expected an interface name"); + final interfaces = _parseImplementsInterfaces(); final directives = _parseDirectives(isConst: true); final fields = _parseFieldsDefinition(); return InterfaceTypeDefinitionNode( description: description, name: name, + interfaces: interfaces, directives: directives, fields: fields, ); diff --git a/gql/lib/src/language/printer.dart b/gql/lib/src/language/printer.dart index e50b1d1d..b602127c 100644 --- a/gql/lib/src/language/printer.dart +++ b/gql/lib/src/language/printer.dart @@ -435,6 +435,7 @@ class _PrintVisitor extends Visitor { " ", node.name.accept(this), " ", + visitImplementsSetNode(node.interfaces), visitDirectiveSetNode(node.directives), visitFieldSetNode(node.fields), ].join();