Flutter Ferry library for graphql. ferry_generator producing error

788 views Asked by At

I am implementing graphql in my flutter project using Ferry. However upon following the installation process. I came across a loop on the build runner unable to generate the schema for the graphql.

PS THE_PROJECT_PATH > flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 597ms

[WARNING] Invalidated precompiled build script due to missing asset graph.
[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 1.4s

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 923ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms

[INFO] Running build...
[SEVERE] ferry_generator:req_builder on lib/graphql/schema.graphql:

FormatException: Invalid UTF-8 byte (at offset 0)                       /// the error occured here
[SEVERE] ferry_generator:req_builder on lib/graphql/schema.graphql:

FormatException: Invalid UTF-8 byte (at offset 0)
[INFO] 1.1s elapsed, 1/2 actions completed.
[INFO] 2.1s elapsed, 1/2 actions completed.
[INFO] 3.2s elapsed, 1/2 actions completed.
[INFO] 4.3s elapsed, 1/2 actions completed.
[INFO] 5.4s elapsed, 1/2 actions completed.
[INFO] 6.5s elapsed, 1/2 actions completed.
[INFO] 7.6s elapsed, 1/2 actions completed.
[INFO] 8.7s elapsed, 1/2 actions completed.
[INFO] 9.8s elapsed, 1/2 actions completed.
[INFO] 10.8s elapsed, 1/2 actions completed.
[INFO] 11.9s elapsed, 1/2 actions completed.
[INFO] 13.0s elapsed, 1/2 actions completed.
[INFO] 14.1s elapsed, 1/2 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:
  - gql_build:data_builder on lib/graphql/schema.graphql

[INFO] 16.2s elapsed, 1/2 actions completed.
[INFO] 17.3s elapsed, 1/2 actions completed.
[INFO] 18.4s elapsed, 1/2 actions completed.
[INFO] 19.4s elapsed, 1/2 actions completed.
[INFO] 20.5s elapsed, 1/2 actions completed.
[INFO] 21.6s elapsed, 1/2 actions completed.
[INFO] 22.6s elapsed, 1/2 actions completed.
[INFO] 23.7s elapsed, 1/2 actions completed.
[INFO] 24.7s elapsed, 1/2 actions completed.
[INFO] 25.8s elapsed, 1/2 actions completed.
[INFO] 26.9s elapsed, 1/2 actions completed.


... // And it didn't stop and looped for ever, I need to force stop

I have tried re-creating the project with the same dependency however same outcome.

2

There are 2 answers

0
prem kumar On

This error is because running get-graphql-schema [ENDPOINT_URL] > lib/schema.graphql will generate schema.graphql in different file encoding than utf-8. you need to copy the contents of the generated schema.graphql and create different schema.graphql file yourself and paste the content and different the generated one.

0
Darkhorse On

The Ferry documentation states this: "If our GraphQL schema includes custom scalar types, we'll need to configure Ferry's code generator to properly handle them".

https://ferrygraphql.com/docs/custom-scalars/