comigor/artemis

Fragment definition nodes from other files are not included

mvarendorff opened this issue · 4 comments

Before reporting a bug, please test the beta branch! (✅)

Bug description

When placing GraphQL fragments in a separate file, they are not included in the generated code. This limits reusability of fragments to only a single file. Note: I am not sure if splitting fragments and queries into multiple files is allowed in the GraphQL spec but all web frontend libraries I have used so far supported it.

Specs

Artemis version: 7.1.1-beta.1

build.yaml:
targets:
  $default:
    builders:
      artemis:
        options:
          schema_mapping:
            - schema: lib/schema.graphql
              queries_glob: lib/**/*.graphql
              output: lib/graphql/api.dart
          scalar_mapping:
            - graphql_type: Uuid
              dart_type: String
            - graphql_type: DateTime
              dart_type: DateTime
            - graphql_type: Long
              dart_type: int
Artemis output:
# Please paste the output of
[ +150 ms] executing: [C:\development\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +159 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] d79295af24c3ed621c33713ecda14ad196fd9c31
[   +1 ms] executing: [C:\development\flutter/] git tag --points-at d79295af24c3ed621c33713ecda14ad196fd9c31
[ +108 ms] Exit code 0 from: git tag --points-at d79295af24c3ed621c33713ecda14ad196fd9c31
[        ] 2.2.2
[   +9 ms] executing: [C:\development\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +44 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [C:\development\flutter/] git ls-remote --get-url origin
[  +85 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +418 ms] executing: [C:\development\flutter/] git rev-parse --abbrev-ref HEAD
[ +150 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[ +163 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +8 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] 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.
[ +129 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] 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.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +112 ms] Using C:\development\flutter\.pub-cache for the pub cache.
[   +1 ms] executing: C:\development\flutter\bin\cache\dart-sdk\bin\pub run build_runner build --verbose
[INFO] Entrypoint:Generating build script...
[INFO] Entrypoint:Generating build script completed, took 1.1s

[INFO] BuildDefinition:Initializing inputs
[INFO] BuildDefinition:Reading cached asset graph...
[INFO] BuildDefinition:Reading cached asset graph completed, took 348ms

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

[INFO] Build:Running build...
[INFO] Heartbeat:1.4s elapsed, 1/2 actions completed.
[INFO] Heartbeat:2.8s elapsed, 1/2 actions completed.
[INFO] Heartbeat:4.1s elapsed, 1/2 actions completed.
[INFO] Heartbeat:5.3s elapsed, 1/2 actions completed.
[INFO] Heartbeat:6.3s elapsed, 1/2 actions completed.
[INFO] Heartbeat:7.4s elapsed, 1/2 actions completed.
[INFO] Heartbeat:8.7s elapsed, 1/2 actions completed.
[INFO] Heartbeat:9.8s elapsed, 1/2 actions completed.
[INFO] Heartbeat:10.9s elapsed, 1/2 actions completed.
[INFO] Heartbeat:12.2s elapsed, 1/2 actions completed.
[INFO] Heartbeat:13.5s elapsed, 1/2 actions completed.
[INFO] Heartbeat:14.5s elapsed, 1/2 actions completed.
[INFO] Heartbeat:15.6s elapsed, 1/2 actions completed.
[INFO] Heartbeat:45.9s elapsed, 1/2 actions completed.
[WARNING] Heartbeat:
No actions completed for 44.6s, waiting on:
  - json_serializable:json_serializable on lib/routes/map/map/components/map_filter.dart

[FINE] json_serializable:json_serializable on lib/routes/map/map/components/map_filter.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/routes/map/map/components/map_filter.dart:Running JsonLiteralGenerator - 2 of 2
[INFO] Heartbeat:47.6s elapsed, 2/18 actions completed.
[INFO] Heartbeat:48.7s elapsed, 5/20 actions completed.
[INFO] Heartbeat:50.6s elapsed, 12/28 actions completed.
[INFO] Heartbeat:51.7s elapsed, 16/32 actions completed.
[INFO] Heartbeat:52.8s elapsed, 23/38 actions completed.
[INFO] Heartbeat:53.9s elapsed, 29/45 actions completed.
[INFO] Heartbeat:54.9s elapsed, 41/45 actions completed.
[INFO] Build:Running build completed, took 55.2s

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

[INFO] Build:Succeeded after 55.5s with 0 outputs (45 actions)

[+68929 ms] "flutter pub" took 69.228ms.
[ +102 ms] ensureAnalyticsSent: 90ms
[   +4 ms] Running shutdown hooks
[   +1 ms] Shutdown hooks complete
[   +2 ms] exiting with code 0
GraphQL schema:
schema {
    query: Query
    mutation: Mutation
}

type Example {
    id: Uuid!
    name: String!
}

type Query {
    example: Example!
}

type Mutation {
    login: Boolean!
}

scalar Uuid
GraphQL query:
# a.graphql
query ExampleQuery {
    example {
        ...ExampleFragment
    }
}

# b.graphql

fragment ExampleFragment on Example {
    id
    name
}

# Artemis errors on graphql files without mutation or query; this is neither used, nor functional
mutation Login {
    login
}

That requires me to place all fragments that I want to share between query files into one file however, doesn't it (at least that's my understanding of "file", eventhough the config field is called glob)? I have been fiddling around with another codegen package which supports sharing fragments between graphql files out of the box without any configuration required so I am quite surprised to find out this needs configuring in artemis.

This is how it works for now.
Maybe some day we will improve the behavior

Certainly understandable! Thanks for your fast responses :)