Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
removed useless field definition visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilich6107 committed Feb 21, 2020
1 parent f6d3d30 commit 6a2b633
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
2 changes: 0 additions & 2 deletions lib/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ QueryDefinition generateQuery(
final className = ReCase(queryName).pascalCase;

final schemaVisitor = SchemaDefinitionVisitor();
final fieldVisitor = FieldDefinitionVisitor();
final objectVisitor = ObjectTypeDefinitionVisitor();

schema.accept(schemaVisitor);
schema.accept(objectVisitor);
schema.accept(fieldVisitor);

final rootTypeName = schemaVisitor.schemaDefinitionNode.operationTypes
.firstWhere((e) => e.operation == operation.type, orElse: () => null)
Expand Down
25 changes: 0 additions & 25 deletions lib/visitor.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
import 'package:gql/ast.dart';

/// Visits all field definition nodes recursively
class FieldDefinitionVisitor extends RecursiveVisitor {
/// Stores all field definition nodes
Iterable<FieldDefinitionNode> types = [];

@override
void visitFieldDefinitionNode(
FieldDefinitionNode node,
) {
types = types.followedBy([node]);
super.visitFieldDefinitionNode(node);
}

/// Gets object field definition node by operation name
FieldDefinitionNode getByName(String name) {
final type = types.where((type) => type.name.value == name);

if (type.isNotEmpty) {
return type.first;
}

return null;
}
}

/// Visits all object definition nodes recursively
class ObjectTypeDefinitionVisitor extends RecursiveVisitor {
/// Stores all object definition nodes
Expand Down

0 comments on commit 6a2b633

Please sign in to comment.