Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum containing uppercase dart keyword #196

Closed
ghost opened this issue Aug 10, 2020 · 4 comments
Closed

Enum containing uppercase dart keyword #196

ghost opened this issue Aug 10, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Aug 10, 2020

Bug description
Enums containing UPPERCASE dart keywords (IN, FOR, etc...) causes generator to break.

Works as expected if the keyword is lowercase (in => kw$in)

Enum SQLOperator {
  EQ
  in
}
enum SQLOperator {
  @JsonValue("EQ")
  eq,
  @JsonValue("in")
  kw$in,
  @JsonValue("ARTEMIS_UNKNOWN")
  artemisUnknown,
}

But this doesn't work:

Enum SQLOperator {
  EQ
  IN
}
line 33, column 39: Expected an identifier.
   ╷
33 │   @JsonValue("EQ")eq, @JsonValue("IN")in, @JsonValue("ARTEMIS_UNKNOWN")artemisUnknown,

#116

Specs
Artemis version: 6.6.4-beta.1

build.yaml:
targets:
  $default:
    sources:
      - lib/**
      - graphql/**
      - schema.graphql
    builders:
      artemis:
        options:
          schema_mapping:
            - schema: schema.graphql
              queries_glob: graphql/*.graphql
              output: lib/graphql_api.dart
Artemis output:
[ +135 ms] executing: [C:\flutter\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +74 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] 2ae34518b87dd891355ed6c6ea8cb68c4d52bb9d
[   +2 ms] executing: [C:\flutter\flutter/] git tag --contains HEAD
[ +251 ms] Exit code 0 from: git tag --contains HEAD
[   +1 ms] 1.20.1
[  +14 ms] executing: [C:\flutter\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +52 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +1 ms] origin/stable
[        ] executing: [C:\flutter\flutter/] git ls-remote --get-url origin
[  +59 ms] Exit code 0 from: git ls-remote --get-url origin
[   +1 ms] https://github.com/flutter/flutter.git
[  +95 ms] executing: [C:\flutter\flutter/] git rev-parse --abbrev-ref HEAD
[  +48 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +69 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[   +6 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +7 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[   +8 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +24 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[   +8 ms] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[  +10 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[  +12 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[   +4 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[  +12 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[   +2 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[   +8 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[  +47 ms] Using C:\flutter\flutter\.pub-cache for the pub cache.
[   +1 ms] executing: C:\flutter\flutter\bin\cache\dart-sdk\bin\pub.bat run build_runner build --verbose
[INFO] Generating build script...
[INFO] Generating build script completed, took 445ms

[WARNING] build.fallback:
The package `flutter_artemis_test` does not include some required sources in any of its targets (see their build.yaml file).
The missing sources are:
  - $package$
[INFO] BuildDefinition:Initializing inputs
[INFO] BuildDefinition:Reading cached asset graph...
[INFO] BuildDefinition:Reading cached asset graph completed, took 79ms

[INFO] BuildDefinition:Checking for updates since last build...
[INFO] BuildDefinition:Checking for updates since last build completed, took 1.0s

[INFO] Build:Running build...
[FINE] artemis:artemis on lib/$lib$:-> Input class
[FINE] artemis:artemis on lib/$lib$:┌ [][ArticleTitleWhereConditions]
[FINE] artemis:artemis on lib/$lib$:|   [][ArticleTitleWhereConditions][ClassName(name:r'SQLOperator') ClassPropertyName(name:r'operator')] -> SQLOperator 
[FINE] artemis:artemis on lib/$lib$:|   [][ArticleTitleWhereConditions][ClassName(name:r'String') ClassPropertyName(name:r'value')] -> String
[FINE] artemis:artemis on lib/$lib$:└ [][ArticleTitleWhereConditions]
[FINE] artemis:artemis on lib/$lib$:<- Generated input class ArticleTitleWhereConditions.
[FINE] artemis:artemis on lib/$lib$:-> Enum
[FINE] artemis:artemis on lib/$lib$:<- Generated enum SQLOperator.
[FINE] artemis:artemis on lib/$lib$:-> Class
[FINE] artemis:artemis on lib/$lib$:┌ [TypeName(name:r'SearchArticles'), TypeName(name:r'Query')][Query][null null] ()
[FINE] artemis:artemis on lib/$lib$:|   [TypeName(name:r'SearchArticles'), TypeName(name:r'Query')][Query][ClassName(name:r'Article') ClassPropertyName(name:r'articles')] -> List<SearchArticles$Query$Article>
[FINE] artemis:artemis on lib/$lib$:|   -> Class
[FINE] artemis:artemis on lib/$lib$:|   ┌ [TypeName(name:r'SearchArticles'), TypeName(name:r'Query'), ClassName(name:r'Article')][Article][null null] ()   
[FINE] artemis:artemis on lib/$lib$:|   |   [TypeName(name:r'SearchArticles'), TypeName(name:r'Query'), ClassName(name:r'Article')][Article][ClassName(name:r'ID') ClassPropertyName(name:r'id')] -> String
[FINE] artemis:artemis on lib/$lib$:|   |   [TypeName(name:r'SearchArticles'), TypeName(name:r'Query'), ClassName(name:r'Article')][Article][ClassName(name:r'String') ClassPropertyName(name:r'title')] -> String
[FINE] artemis:artemis on lib/$lib$:|   └ [TypeName(name:r'SearchArticles'), TypeName(name:r'Query'), ClassName(name:r'Article')][Article][null null] ()   
[FINE] artemis:artemis on lib/$lib$:|   <- Generated class SearchArticles$Query$Article.
[FINE] artemis:artemis on lib/$lib$:└ [TypeName(name:r'SearchArticles'), TypeName(name:r'Query')][Query][null null] ()
[FINE] artemis:artemis on lib/$lib$:<- Generated class SearchArticles$Query.
[SEVERE] artemis:artemis on lib/$lib$:

Could not format because the source could not be parsed:

line 33, column 39: Expected an identifier.
   ╷
33 │   @JsonValue("EQ")eq, @JsonValue("IN")in, @JsonValue("ARTEMIS_UNKNOWN")artemisUnknown,
   │                                       ^^
   ╵
package:dart_style/src/dart_formatter.dart 142:7                        DartFormatter.formatSource
package:dart_style/src/dart_formatter.dart 74:12                        DartFormatter.format
package:artemis/generator/print_helpers.dart 386:26                     specToString
package:artemis/generator/print_helpers.dart 394:16                     writeLibraryDefinitionToBuffer
package:artemis/builder.dart 148:7                                      GraphQLQueryBuilder.build
package:build                                                           runBuilder
package:build_runner_core/src/generate/build_impl.dart 485:19           _SingleBuild._runForInput.<fn>.<fn>.<fn>
package:build_runner_core/src/generate/performance_tracker.dart 302:15  _NoOpBuilderActionTracker.trackStage
package:build_runner_core/src/generate/build_impl.dart 483:23           _SingleBuild._runForInput.<fn>.<fn>
package:build_runner_core/src/generate/build_impl.dart                  _SingleBuild._runForInput.<fn>.<fn>
package:timing/src/timing.dart 222:44                                   NoOpTimeTracker.track
package:build_runner_core/src/generate/build_impl.dart 440:22           _SingleBuild._runForInput.<fn>
package:pool/pool.dart 127:28                                           Pool.withResource
package:build_runner_core/src/generate/build_impl.dart 436:17           _SingleBuild._runForInput
package:build_runner_core/src/generate/build_impl.dart 374:38           _SingleBuild._runBuilder.<fn>
dart:async                                                              Future.wait
package:build_runner_core/src/generate/build_impl.dart 373:36           _SingleBuild._runBuilder
package:build_runner_core/src/generate/build_impl.dart 319:20           _SingleBuild._runPhases.<fn>.<fn>
package:build_runner_core/src/generate/build_impl.dart                  _SingleBuild._runPhases.<fn>.<fn>
package:build_runner_core/src/generate/performance_tracker.dart 184:15  _NoOpBuildPerformanceTracker.trackBuildPhase
package:build_runner_core/src/generate/build_impl.dart 315:47           _SingleBuild._runPhases.<fn>
package:timing/src/timing.dart 222:44                                   NoOpTimeTracker.track
package:build_runner_core/src/generate/build_impl.dart 309:32           _SingleBuild._runPhases
package:build_runner_core/src/logging/logging.dart 25:30                logTimedAsync
package:build_runner_core/src/generate/build_impl.dart 266:26           _SingleBuild._safeBuild.<fn>
dart:async                                                              runZoned
package:build_runner_core/src/generate/build_impl.dart 261:5            _SingleBuild._safeBuild
package:build_runner_core/src/generate/build_impl.dart 208:24           _SingleBuild.run
package:build_runner_core/src/generate/build_impl.dart 94:56            BuildImpl.run
package:build_runner_core/src/generate/build_runner.dart 25:14          BuildRunner.run
package:build_runner                                                    BuildCommand.run
package:args/command_runner.dart 197:27                                 CommandRunner.runCommand
package:args/command_runner.dart 112:25                                 CommandRunner.run.<fn>
dart:async                                                              new Future.sync
package:args/command_runner.dart 112:14                                 CommandRunner.run
package:build_runner                                                    run
.dart_tool\build\entrypoint\build.dart 31:22                            main

[INFO] Build:Running build completed, took 515ms

[INFO] Build:Caching finalized dependency graph...
[INFO] Build:Caching finalized dependency graph completed, took 97ms

[SEVERE] Build:
Failed after 629ms
[+4484 ms] "flutter run" took 4,672ms.
[  +11 ms] pub finished with exit code 1
[   +5 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
           #1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:361:7)
           <asynchronous suspension>
           #2      PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:235:15)
           #3      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:860:18)
           #4      _rootRunUnary (dart:async/zone.dart:1198:47)
           #5      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
           #6      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
           #7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
           #8      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
           #9      Future._completeWithValue (dart:async/future_impl.dart:529:5)
           #10     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
           #11     _rootRun (dart:async/zone.dart:1190:13)
           #12     _CustomZone.run (dart:async/zone.dart:1093:19)
           #13     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
           #14     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
           #15     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
           #16     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
           #17     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
           #18     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)


[ +278 ms] ensureAnalyticsSent: 259ms
[   +3 ms] Running shutdown hooks
[   +1 ms] Shutdown hooks complete
[   +1 ms] exiting with code 1
GraphQL schema:
type Query {
    articles(titleWhere: ArticleTitleWhereConditions): [Article!]
}

input ArticleTitleWhereConditions {
    operator: SQLOperator
    value: String
}

type Article {
  id: ID!
  title: String!
}

enum SQLOperator {
  EQ
  IN
}
GraphQL query:
query SearchArticles($titleWhere: ArticleTitleWhereConditions) {
    articles(titleWhere: $titleWhere) {
        id
        title
    }
}
@ghost ghost added the bug Something isn't working label Aug 10, 2020
@vasilich6107
Copy link
Collaborator

Good catch. I'll take a look

@vasilich6107
Copy link
Collaborator

Try this branch uppercase-keyword-fix

@ghost
Copy link
Author

ghost commented Aug 11, 2020

@vasilich6107
uppercase-keyword-fix is working good! Thank you 👍

@vasilich6107
Copy link
Collaborator

Fixed in v6.7.1-beta.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant