You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that in GQL I use Optional<_> fields that are actually required, because how GQL interact in Apollo Federation (for example when error is returned for some subgraph the supergraph can still return partial data if field is optional). Adding #[graphql(optioanl)] make Rust code easier to write and at the same time make GQL as expected.
Code example (if possible)
#[derive(Debug,SimpleObject)]#[graphql(shareable)]// maybe #[graphql(all_fileds_optional)] that can be useful for structures used in Union? structObject{#[graphql(optional)]// this field should never be null in our service but can be in othersname:String,/// this field is sometime nullopt_filed:Option<String>,}
The text was updated successfully, but these errors were encountered:
@Miaxos of course it will work - but you need to do a lot of Some(_) and also you can accidentally set value to None. With above you can have rust type checking system on your side. This would be only for fields that can't be null but in GQL schema are marked as nullable.
EDIT: updated example code to make sure that it's intentional and feature request is just syntax sugar.
xoac
changed the title
Add #[graphql(optional)] for fields
Add #[graphql(optional)] for fields (provde less boilerplate and more correctness)
Jan 8, 2024
Description of the feature
I found that in GQL I use Optional<_> fields that are actually required, because how GQL interact in Apollo Federation (for example when error is returned for some subgraph the supergraph can still return partial data if field is optional). Adding
#[graphql(optioanl)]
make Rust code easier to write and at the same time make GQL as expected.Code example (if possible)
The text was updated successfully, but these errors were encountered: