Giter Site home page Giter Site logo

artflutter / graphql_flutter_bloc Goto Github PK

View Code? Open in Web Editor NEW
49.0 6.0 10.0 489 KB

BLOC wrapper over `graphql_flutter` streams with improved state handling.

License: MIT License

Dart 88.93% Swift 0.38% Objective-C 0.01% Ruby 0.79% JavaScript 1.14% Kotlin 0.04% HTML 1.15% CMake 2.41% C++ 4.94% C 0.22%
graphql dart flutter bloc

graphql_flutter_bloc's Introduction

graphql_flutter_bloc

BLOC wrapper over graphql_flutter streams with improved state handling.

Installation

  • use v0.3.* for graphql_flutter v3 - this version is not supported anymore
  • use v > 0.4.* for graphql_flutter v4

How to use

Clone this repo and launch the example project. It will help you to understand how to use this lib for Query and Mutation.

graphql_flutter_bloc's People

Contributors

vasilich6107 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

graphql_flutter_bloc's Issues

How to use graphql-yoga server in this project

Since this project demonstrates bloc subscriptions, could you include in the readme how to set up and use graphql-yoga?

It's new to me how graphql-faker makes it so easy to mock up a local graphql schema but I believe that its server does not support subscriptions, which is why you included the subscription_server folder in the project, but is there a way to create a fake schema for the graphql-yoga server or even use the same fake.schema?

Issue when refetching.

When trying to refetch the data after the page gets disposed and initialized again, it throws an error.

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Unhandled error Exception: Query is not refetch safe occurred in Instance of 'PostsBloc'.
#0      ObservableQuery.refetch
#1      QueryBloc._refetch
<asynchronous suspension>
#0      BlocBase.onError.<anonymous closure>
#1      BlocBase.onError
#2      _rootRunBinary (dart:async/zone.dart:1452:47)
#3      _CustomZone.runBinary (dart:async/zone.dart:1342:19)
#4      _CustomZone.runBinaryGuarded (dart:async/zone.dart:1252:7)
#5      _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:360:15)
#6      _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:378:7)
#7      _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:280:7)
#8      _SyncBroadcastStreamController._sendError.<anonymous closure> (dart:async/broadcast_stream_controller.dart:393:20)
#9      _BroadcastStreamController._forEachListener (dart:async/broadcast_stream_controller.dart:323:15)
#10     _SyncBroadcastStreamController._sendError (dart:async/broadcast_stream_controller.dart:392:5)
#11     _BroadcastStreamController._addError (dart:async/broadcast_stream_controller.dart:290:5)
#12     _rootRunBinary (dart:async/zone.dart:1452:47)
#13     _CustomZone.runBinary (dart:async/zone.dart:1342:19)
#14     _CustomZone.runBinaryGuarded (dart:async/zone.dart:1252:7)
#15     _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:360:15)
#16     _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:378:7)
#17     _BufferingStreamSubscription._addError (dart:async/stream_impl.dart:280:7)
#18     _ForwardingStreamSubscription._addError (dart:async/stream_pipe.dart:128:11)
#19     _ForwardingStream._handleError (dart:async/stream_pipe.dart:95:10)
#20     _ForwardingStreamSubscription._handleError (dart:async/stream_pipe.dart:157:13)
#21     _rootRunBinary (dart:async/zone.dart:1452:47)
#22     _CustomZone.runBinary (dart:async/zone.dart:1342:19)
#23     _CustomZone.runBinaryGuarded (dart:async/zone.dart:1252:7)
#24     _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:360:15)
#25     _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:378:7)
#26     _DelayedError.perform (dart:async/stream_impl.dart:602:14)
#27     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
#28     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
#29     _rootRun (dart:async/zone.dart:1420:47)
#30     _CustomZone.run (dart:async/zone.dart:1328:19)
#31     _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#32     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
#33     _rootRun (dart:async/zone.dart:1428:13)
#34     _CustomZone.run (dart:async/zone.dart:1328:19)
#35     _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#36     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
#37     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#38     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

And it directs me to this;

 /// Attempts to refetch _on the network_, throwing error if not refetch safe
  ///
  /// **NOTE:** overrides any present non-network-only [FetchPolicy],
  /// as refetching from the `cache` does not make sense.
  Future<QueryResult?> refetch() {
    if (isRefetchSafe) {
      addResult(QueryResult.loading(data: latestResult?.data));
      return queryManager.refetchQuery(queryId);
    }
    throw Exception('Query is not refetch safe');
  }

Note that this only happens once I go into a different page and the Posts Page gets disposed.. When I return back to the Posts Page, even tho it initialize it again but the second time when trying to refetch it throws the error above.
I've tried to change the FetchPolicy to FetchPolicy.networkOnly but nothing changes.

Best regards.

How to generate q.schema.graphql / models/graphql ?

I wanted to combine graphql_flutter with flutter_bloc and found out that this repo is the way the developers of graphql_flutter recommend to use. But I have no idea how to generate some files seen in the example... I think I am missing something and since the documentation is not existing except for an example and obviously not many people have use the repo I ask for your help here:

How is https://github.com/artflutter/graphql_flutter_bloc/blob/master/example/graphql/q/q.schema.graphql generated? It says "# This file was generated based on ".graphqlconfig". Do not edit manually."

Same for all the files in https://github.com/artflutter/graphql_flutter_bloc/tree/master/example/lib/models/graphql where it says "// GENERATED CODE - DO NOT MODIFY BY HAND"

And another question: Is this repo active? I have not found any information of other people using it so far and I am a bit scared to recode a lot of parts of my app without being future proof.

Thanks for your response!

build error

I followed the instructions in README.md

At the last step flutter run gives me this build error.

any idea how I can solve it?

Thanks a lot for the awesome package.

Running Xcode build...
Xcode build done.
28.4s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
    	/var/folders/j9/vgh6xy2d29b5hqw04ppdbxb40000gn/T/flutter_
    	tools.x5Kilp/flutter_ios_build_temp_dirfr32p0/temporary_x
    	cresult_bundle

    ../../../../../../flutter/.pub-cache/hosted/pub.dartlang.o
    rg/graphql-5.0.0/lib/src/core/query_manager.dart:427:23:
    Error: Required named parameter 'response' must be
    provided.
                  Response(data: cachedData),
                          ^
    ../../../../../../flutter/.pub-cache/hosted/pub.dartlang.o
    rg/gql_exec-0.3.2-alpha+1635885531651/lib/src/response.dar
    t:23:9: Context: Found this candidate, but the arguments
    don't match.
      const Response({
            ^^^^^^^^
    Failed to package
    /Users/zirho6/Documents/Projects/sideProjects/aq/flutter-a
    pps/graphql_flutter_bloc/example.
    Command PhaseScriptExecution failed with a nonzero exit
    code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order

    Result bundle written to path:
    	/var/folders/j9/vgh6xy2d29b5hqw04ppdbxb40000gn/T/flutter_
    	tools.x5Kilp/flutter_ios_build_temp_dirfr32p0/temporary_x
    	cresult_bundle


Could not build the application for the simulator.
Error launching application on iPhone 13.

update dependencies

I install google_fonts : ^6.0.0. But this package depends on http ^1.0.0, and your package depends on http ^0.13.5, so the installation failed. Can you update dependencies of your package? Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.