Is your feature request related to a problem? Please describe.
I am currently using the graphql_flutter package for GraphQL in my Flutter application. However, I've used Relay before in React and I like its philosophy of compiling fragments into a full query so that the application never over or underfetches data. It uses a useFragment hook to do so. This feature allows components to specify their data requirements and automatically subscribe to updates to the fragment data.
Describe the solution you'd like
I would like to see the addition of a useFragment hook or a similar feature in the graphql_flutter package. This feature should allow Flutter components to specify their data requirements using GraphQL fragments. The components should then be automatically subscribed to updates to the fragment data. If the data for the specified fragment is updated anywhere in the app, the component should automatically re-render with the latest updated data.
Describe alternatives you've considered
While there are other GraphQL packages available for Flutter, none of them seem to offer a feature similar to Relay's useFragment hook. I have not been able to find something similar.
Is your feature request related to a problem? Please describe. I am currently using the
graphql_flutter
package for GraphQL in my Flutter application. However, I've used Relay before in React and I like its philosophy of compiling fragments into a full query so that the application never over or underfetches data. It uses auseFragment
hook to do so. This feature allows components to specify their data requirements and automatically subscribe to updates to the fragment data.Describe the solution you'd like I would like to see the addition of a
useFragment
hook or a similar feature in thegraphql_flutter
package. This feature should allow Flutter components to specify their data requirements using GraphQL fragments. The components should then be automatically subscribed to updates to the fragment data. If the data for the specified fragment is updated anywhere in the app, the component should automatically re-render with the latest updated data.Describe alternatives you've considered While there are other GraphQL packages available for Flutter, none of them seem to offer a feature similar to Relay's
useFragment
hook. I have not been able to find something similar.There's a good article on the benefits of a Relay style approach over the more popular Apollo approach, and even Apollo is creating their own
useFragment
hook and implementation, as well as the team behind GraphQL codegen designing a similar approach too.