ferry
ferry copied to clipboard
How to add multiple schema.graphql files?
Hi,
I want to play around with ferry a little bit and want to add two different schema files. However I cant generate the ferry classes when I run the build_runner
File structure:
And this is my build.yaml
targets:
$default:
builders:
ferry_generator|graphql_builder:
generate_for:
- lib/graphql/countries/**
enabled: true
options:
schema: blocbloc|lib/graphql/countries/schema.graphql
output_dir: 'graphql_generated'
when_extensions:
when: true
maybeWhen: true
ferry_generator|serializer_builder:
enabled: true
options:
schema: blocbloc|lib/graphql/countries/schema.graphql
output_dir: 'graphql_generated'
when_extensions:
when: true
maybeWhen: true
movieapi:
builders:
ferry_generator|graphql_builder:
generate_for:
- lib/graphql/movies/**
enabled: true
options:
schema: blocbloc|lib/graphql/movies/schema.graphql
output_dir: 'generated'
when_extensions:
when: true
maybeWhen: true
ferry_generator|serializer_builder:
enabled: true
options:
schema: blocbloc|lib/graphql/movies/schema.graphql
output_dir: 'generated'
when_extensions:
when: true
maybeWhen: true
If I do a
flutter pub run build_runner build --delete-conflicting-outputs
I always get the following error:
Both built_value_generator:built_value and built_value_generator:built_value may output lib/client_injector.built_value.g.part. Potential outputs must be unique across all builders. See https://github.com/dart-lang/build/blob/master/docs/faq.md#why-do-builders-need-unique-outputs
The file is just a dart file that does nothing, its under /lib
What am I doing wrong?
Update:
I added
sources:
include:
- lib/graphql/movies/**
to the seconds target movieapi, now the files get generated, however the serializer files seem to be not get generatred, when I add a query file
Can somebody help?
Generally, I'd recommend just connecting to one graphql API.
If you have two different servers, you could use for example Apollo Router or other means of graphql federation to combine your APIs to one central point.
Right now, ferry only supports one schema per package. But you can create a second package just for the schema, the queries and the generated code of the second schema and import that second package from the main package
Hi @knaeckeKami
Thanks for your reply!
As it turned out, I really wont need a second schema in my current project. Would be very cool if this gets supported in future though.
This issue can be closed I guess :)