Giter Club home page Giter Club logo

flutter-graphql's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter-graphql's Issues

Question: Purpose of "getOperationName" function

While looking through the source of this package, I found this comment:
https://github.com/snowballdigital/flutter-graphql/blob/master/lib/src/core/query_manager.dart#L67-L68:

// XXX there is a bug in the `graphql_parser` package, where this result might be
// null event though the operation name is present in the document

I am the creator/maintainer of the graphql_parser package. Can you provide some details about the bug you are referring to?

In a query like this:

{
  foo,
  bar: baz
  ...quux
  ... on A {b, c}
}

There is no operation name, and this a pretty common case.

Is it possible that the query you were using simply didn't have an operation name? Otherwise, if you can provide a repro, I can fix it.

pollInterval should not poll the server when set to zero

Describe the bug
When pollInterval is set to zero, it constantly polls to the server, without stopping. Since it follows Apollo GrapphQL patterns, this should disable polling altogether.

To Reproduce

Set pollInterval to 0 at QueryOptions

Expected behavior
Should disable polling altogether

Relies on an older version of path_provider

Would it be possible to update the path_provider dependency to the latest version, i am getting incompatible since it requires version ^0.4.1 and using Cached Network Image which is on version ^0.5.0+1.

Because cached_network_image >=0.7.0 depends on flutter_cache_manager ^0.3.2 which depends on path_provider ^0.5.0+1, cached_network_image >=0.7.0 requires path_provider ^0.5.0+1.

And because flutter_graphql 1.0.0-rc.3 depends on path_provider ^0.4.1 and no versions of flutter_graphql match >1.0.0-rc.3 <2.0.0, cached_network_image >=0.7.0 is incompatible with flutter_graphql ^1.0.0-rc.3.

subscription foreground

Is your feature request related to a problem? Please describe.
now I can't send a request in the background, as well as send and subscribe

Describe the solution you'd like
i don't no :(

Describe alternatives you've considered
i propabbly use this package https://pub.dev/packages/workmanager

Additional context
Add any other context or screenshots about the feature request here.

Problem with subscription

Hello, I have a problem with Graphql subscription. When I try with graphql playground - all works fine: on the server I receive an answer about subscription, but when I trying to connect in flutter - I'm getting only loading true on the client, but nothing on the server.

import 'package:flutter/material.dart';
import 'package:flutter_graphql/flutter_graphql.dart';

void main() async {
  socketClient = await SocketClient.connect('ws://address',
    headers: {
      'authorization': "accessTokenHere"
    }
  );

  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    final title = 'WebSocket Demo';
    return MaterialApp( 
      title: title,
      home: MyHomePage(
        title: title,
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  MyHomePage({Key key, @required this.title})
      : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController _controller = TextEditingController();

  static String operationName = "notification";
  String query = """subscription $operationName{
    notification{
      messageCount
    }
  }""".replaceAll('\n', ' ');

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(20.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Form(
              child: TextFormField(
                controller: _controller,
                decoration: InputDecoration(labelText: 'Send a message'),
              ),
            ),
            Subscription(
              operationName,
              query,
              variables: {},
              builder: ({
                bool loading,
                dynamic payload,
                dynamic error,
              }) {
                print(loading);
                print(payload);
                print(error);
                if (payload != null) {
                  return Text(payload['requestSubscription']['requestData']);
                } else {
                  return Text('Data not found');
                }
              }
            ),
          ],
        ),
      ),
    );
  }

}

Comparison with https://github.com/zino-app/graphql-flutter

Hi, this package was originally a fork of https://github.com/zino-app/graphql-flutter: https://github.com/juicycleff/flutter-graphql
Then it transferred to another namespace (snowballdigital) and it lost its reference as a fork of zino-app.

Could you please describe how this package differs from the original package that is still being maintained and what design decisions made you decide to go a different direction (and not try to steer to a single effort, maintained and contributed by more devs?)

We as a team are also willing to contribute, but must decide first what package is the most promising to end up as the project with most traction and community support.

Thanks!

why not transfer ownership?

@juicycleff you can transfer repository ownership, which I think would be less confusing than copy-pasting for end-users, and maintain the github repo-relationship graph
Screen Shot 2019-03-19 at 18 52 25

Loading boolean only set true on initial load

Describe the bug
The loading boolean is only ever true, once. Meaning, if you were to wrap the Query in a StatefulWidget, or a ScopedModelDescendant as in my case, the build method causes the Query to fire off its builder, but the result.loading is never actually set to true to indicate that the Query is loading again.

To Reproduce
Steps to reproduce the behavior:

  1. Construct a StatefulWidget or ScopedModelDescedant, or anything that will fire off a rebuild
  2. Set a Query widget as a child of your StatefulWidget
  3. Create an if statement within the builder for Query to print out "Loading!" when result.loading is true
  4. Add a button or some other trigger that will change the state of the Queries parent, firing the parent's build method
  5. Load the application
  6. Notice that "Loading!" fires on first application load
  7. Press the button / fire the trigger
  8. Notice that "Loading!" does not appear in the log, indicating that result.loading is never reset to true

Expected behavior
This might be my misunderstanding when it comes to the loading boolean, but I anticipated that loading would be set to true whenever the Query is fetching data, and especially when the whole widget is rebuilding.

Screenshots
n/a

Desktop (please complete the following information):

  • OS: Windows
  • Version 10

Smartphone (please complete the following information):

  • Device: Genymotion Emulator
  • OS: Android Pie
  • Version 1.0.0-rc.3

Additional context
I've done some digging around in the query.dart file and I've found that everything appears to initialize as expected when the dependencies change, and the Query widget's internal build method does in fact fire every time we run its StatefulWidget parent's build method, which does in fact set initialData: QueryResult { loading: true } (line 88). My best guess is that this has something to do with not fully closing the stream, or perhaps something to do with the controller? No idea!

Re-sending a failed query

I've integrated the Query widget into my app, and it works just fine the first time it runs. However, I'd like to have a "try again" button if the query fails that would re-send the query. However, I can't figure out how to refresh/re-send a query. I've written the following code so far, and every time I hit "try again", I can see Built event widget tree printed to my console, but the query itself isn't re-sent:

@override Widget build(BuildContext context) {
  print("Built event widget tree");
  const request = '''
  {
    festapp(id:"931") {
      events {
        name
        startsAt
        image
      }
    }
  }
  ''';
  return Query(
      options: QueryOptions(
        document: request,
        fetchPolicy: FetchPolicy.noCache,
        errorPolicy: ErrorPolicy.all,
        pollInterval: 5
      ),
      builder: (QueryResult result) {
        if (result.errors != null) {
          return Center(child:
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(result.errors.toString()),
                CupertinoButton.filled(
                  child: Text("Try again"),
                  onPressed: (){
                    setState((){});
                  },
                )
              ],
            )
          );
        }

        if (result.loading) {
          return Center(
            child: CupertinoActivityIndicator(
              radius: 20,
              animating: true,
            ),
          );
        }

        List events = result.data["festapp"]["events"];

        return ListView.separated(itemBuilder: (context, row) => EventCell(Event.fromAPIData(events[row])),
            separatorBuilder: (context, row) {
              return Container(
                height: 1,
                color: Color.fromARGB(20, 0, 0, 0),
                margin: EdgeInsets.only(left: 8),
              );
            },
            itemCount: events.length);
        }
    );
  }

WANT TO BE A CORE CONTIBUTOR

Do you want to be a core contributor, please drop your names so we can discuss the way forward for the library. We need a very stable GraphQL library for Flutter.

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.