Graphql-flutter: Decouple operation apis from flutter widgets

Created on 19 Oct 2018  路  4Comments  路  Source: zino-app/graphql-flutter

Describe the bug
When using scoped_model in flutter, i'm unable to return subscriptions as streams as the subscriptions are implemented as widgets.

Expected behavior
Being able to subscribe without the use of flutter widgets.

Is there a way to just use pure dart for performing operations such as querying, subscribing and mutating as its not possible to subscribe date in scoped_model using widgets.

All 4 comments

Check the code in my issue: https://github.com/zino-app/graphql-flutter/issues/126

I am subscribing without Subscription widget.

@truongsinh is working on this, and it is critical for #72.
Also from @feinstein:

if I want to make a Query on my BLoC or Reducer or ViewModel or any form of code that's not presentation, I can't

If this library can be used in a Model class, please also provide its use on the Readme. This is very helpful for unit testing and DI, where we can just simulate a query on a model class and serve it to a Presentation Widget.

For now I encourage anyone with urgent need to look into the widget implementations - you might be able to fit the client interaction points to whatever alternative pattern you're using. For instance, for basic Query and Mutation integration, the main things you'll have to port would be:

  • QueryOptions, MutationOptions, and WatchQueryOptions
  • observableQuery management (observableQuery = client.watchQuery(_options);)
  • collecting the observableQuery.stream for usage as in the StreamBuilder

Separation MR at #203

@truongsinh contributed a bloc implementation example. This is similar enough to #72 that I'm going to close it in favor of there, as #203 will solve both at once

Was this page helpful?
0 / 5 - 0 ratings