Skip to content

Commit

Permalink
add interfaces to InterfaceTypeDefinitionNode (gql-dart#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
juancastillo0 committed Oct 25, 2021
1 parent d576118 commit fa112de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gql/lib/src/ast/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,13 @@ class InputValueDefinitionNode extends Node {

class InterfaceTypeDefinitionNode extends TypeDefinitionNode {
final List<FieldDefinitionNode> fields;
final List<NamedTypeNode> interfaces;

const InterfaceTypeDefinitionNode({
this.fields = const [],
StringValueNode? description,
required NameNode name,
this.interfaces = const [],
List<DirectiveNode> directives = const [],
FileSpan? span,
}) : super(
Expand All @@ -833,6 +835,7 @@ class InterfaceTypeDefinitionNode extends TypeDefinitionNode {
name,
description,
directives,
interfaces,
fields,
];
}
Expand Down
2 changes: 2 additions & 0 deletions gql/lib/src/language/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
1 change: 1 addition & 0 deletions gql/lib/src/language/printer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ class _PrintVisitor extends Visitor<String> {
" ",
node.name.accept(this),
" ",
visitImplementsSetNode(node.interfaces),
visitDirectiveSetNode(node.directives),
visitFieldSetNode(node.fields),
].join();
Expand Down

0 comments on commit fa112de

Please sign in to comment.