snowballdigital / flutter-graphql Goto Github PK
View Code? Open in Web Editor NEWA GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package. Built after react apollo
License: MIT License
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package. Built after react apollo
License: MIT License
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.
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
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.
Is the project still being maintained?
I haven't seen it updated for a long time.
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.
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');
}
}
),
],
),
),
);
}
}
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!
@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
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:
builder
for Query to print out "Loading!" when result.loading
is truebuild
methodresult.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):
Smartphone (please complete the following information):
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!
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);
}
);
}
Hello, Query gives old data after mutation - need new, how can I do this without pollInterval (because I can't to do much requests to the server)?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.