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

Commit

Permalink
enum name pascal casing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilich6107 committed Jul 10, 2020
1 parent 0cb309c commit 79bc83b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 6.5.1-beta.1
- enum name pascal casing.

## 6.5.0-beta.1
- Add deprecated annotations in fields.

Expand Down
6 changes: 6 additions & 0 deletions lib/generator/data/enum_definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:artemis/generator/data/enum_value_definition.dart';
import 'package:artemis/generator/data_printer.dart';
import 'package:artemis/generator/helpers.dart';
import 'package:meta/meta.dart';
import 'package:recase/recase.dart';

/// Define a Dart enum parsed from GraphQL schema.
class EnumDefinition extends Definition with DataPrinter {
Expand Down Expand Up @@ -31,6 +32,11 @@ class EnumName extends Name with DataPrinter {
/// Instantiate a enum name definition.
EnumName({String name}) : super(name: name);

@override
String normalize(String name) {
return ReCase(super.normalize(name)).pascalCase;
}

@override
Map<String, Object> get namedProps => {
'name': name,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: artemis
version: 6.5.0-beta.1
version: 6.5.1-beta.1

authors:
- Igor Borges <igor@borges.dev>
Expand Down
57 changes: 16 additions & 41 deletions test/query_generator/enums/filter_enum_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void main() {
}
type QueryRoot {
q(e: InputEnum!, i: Input!): QueryResponse
q(e: input_enum!, i: Input!): QueryResponse
}
input Input {
Expand All @@ -32,7 +32,7 @@ void main() {
B
}
enum InputEnum {
enum input_enum {
C
D
}
Expand Down Expand Up @@ -65,7 +65,7 @@ void main() {
}

const query = r'''
query custom($e: InputEnum!, $i: Input!) {
query custom($e: input_enum!, $i: Input!) {
q(e: $e, i: $i) {
e
}
Expand All @@ -79,46 +79,21 @@ final LibraryDefinition libraryDefinition =
operationName: r'custom',
classes: [
EnumDefinition(name: EnumName(name: r'MyEnum'), values: [
EnumValueDefinition(
name: EnumValueName(name: r'A'),
),
EnumValueDefinition(
name: EnumValueName(name: r'B'),
),
EnumValueDefinition(
name: EnumValueName(
name: r'ARTEMIS_UNKNOWN',
))
EnumValueDefinition(name: EnumValueName(name: r'A')),
EnumValueDefinition(name: EnumValueName(name: r'B')),
EnumValueDefinition(name: EnumValueName(name: r'ARTEMIS_UNKNOWN'))
]),
EnumDefinition(name: EnumName(name: r'InputEnum'), values: [
EnumValueDefinition(
name: EnumValueName(name: r'C'),
),
EnumValueDefinition(
name: EnumValueName(name: r'D'),
),
EnumValueDefinition(
name: EnumValueName(
name: r'ARTEMIS_UNKNOWN',
))
EnumDefinition(name: EnumName(name: r'input_enum'), values: [
EnumValueDefinition(name: EnumValueName(name: r'C')),
EnumValueDefinition(name: EnumValueName(name: r'D')),
EnumValueDefinition(name: EnumValueName(name: r'ARTEMIS_UNKNOWN'))
]),
EnumDefinition(name: EnumName(name: r'_InputInputEnum'), values: [
EnumValueDefinition(
name: EnumValueName(name: r'_E'),
),
EnumValueDefinition(
name: EnumValueName(name: r'_F'),
),
EnumValueDefinition(
name: EnumValueName(name: r'_new'),
),
EnumValueDefinition(
name: EnumValueName(name: r'new'),
),
EnumValueDefinition(
name: EnumValueName(
name: r'ARTEMIS_UNKNOWN',
))
EnumValueDefinition(name: EnumValueName(name: r'_E')),
EnumValueDefinition(name: EnumValueName(name: r'_F')),
EnumValueDefinition(name: EnumValueName(name: r'_new')),
EnumValueDefinition(name: EnumValueName(name: r'new')),
EnumValueDefinition(name: EnumValueName(name: r'ARTEMIS_UNKNOWN'))
]),
ClassDefinition(
name: ClassName(name: r'Custom$_QueryRoot$_QueryResponse'),
Expand Down Expand Up @@ -165,7 +140,7 @@ final LibraryDefinition libraryDefinition =
],
inputs: [
QueryInput(
type: TypeName(name: r'InputEnum'),
type: TypeName(name: r'input_enum'),
name: QueryInputName(name: r'e'),
isNonNull: true,
annotations: [
Expand Down

0 comments on commit 79bc83b

Please sign in to comment.