Skip to content

Commit 1f2e289

Browse files
committed
🎉 Version bump
1 parent f668ada commit 1f2e289

File tree

3 files changed

+100
-69
lines changed

3 files changed

+100
-69
lines changed

CHANGELOG.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
## [0.7.0] - July 22 2018
2+
3+
### Breaking change
4+
5+
n/a
6+
7+
#### Fixes / Enhancements
8+
9+
- Added support for subsciptionsin the client.
10+
- Added the `Subscription` widget. You can no direcly acces streams from Flutter.
11+
12+
#### Docs
13+
14+
- Added instructions for adding subscripton to your poject.
15+
- Updated the `About this project` section.
16+
117
## [0.6.0] - July 19 2018
218

319
### Breaking change
420

5-
- The library now requires your app to be wrapped with the `GraphqlProvider` widget @HofmannZ
6-
- The global `client` variable is no longer available. Instead use the `GraphqlConsumer` widget
21+
- The library now requires your app to be wrapped with the `GraphqlProvider` widget.
22+
- The global `client` variable is no longer available. Instead use the `GraphqlConsumer` widget.
723

824
#### Fixes / Enhancements
925

@@ -46,7 +62,7 @@ n/a
4662

4763
- Query: changed `Timer` to `Timer.periodic` @eusdima
4864
- Minor logic tweak @eusdima
49-
- Use absolute paths in the library @HofmannZ
65+
- Use absolute paths in the library
5066

5167
#### Docs
5268

README.md

+79-64
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,36 @@
1010

1111
## Table of Contents
1212

13+
- [About this project](#about-this-project)
1314
- [Installation](#installation)
1415
- [Usage](#usage)
1516
- [Graphql Provider](#graphql-provider)
1617
- [Queries](#queries)
1718
- [Mutations](#mutations)
19+
- [Subscriptions (Experimental)](#subscriptions-experimental)
1820
- [Graphql Consumer](#graphql-consumer)
19-
- [Offline Cache](#offline-cache)
21+
- [Offline Cache (Experimental)](#offline-cache-experimental)
2022
- [Roadmap](#roadmap)
2123
- [Contributing](#contributing)
2224
- [Contributors](#contributors)
2325

26+
## About this project
27+
28+
GraphQL brings many benefits, both to the client: devices will need less requests, and therefore reduce data useage. And to the programer: requests are arguable, they have the same structure as the request.
29+
30+
The team at Apollo did a great job implenting GraphQL in Swift, Java and Javascript. But unfortunately they're not planning to release a Dart implementation.
31+
32+
This project is filling the gap, bringing the GraphQL spec to yet another programming language. We plan to implement most functionality from the [Apollo GraphQL client](https://github.com/apollographql/apollo-client) and from most features the [React Apollo](https://github.com/apollographql/react-apollo) components into Dart and Flutter respectively.
33+
34+
With that being said, the project lives currently still inside one package. We plan to spilt up the project into multiple smaler packages in the near future, to follow Apollo's modules design.
35+
2436
## Installation
2537

2638
First depend on the library by adding this to your packages `pubspec.yaml`:
2739

2840
```yaml
2941
dependencies:
30-
graphql_flutter: ^0.6.0
42+
graphql_flutter: ^0.7.0
3143
```
3244
3345
Now inside your Dart code you can import it.
@@ -201,6 +213,64 @@ new Mutation(
201213
...
202214
```
203215

216+
### Subscriptions (Experimental)
217+
218+
The syntax for subscriptions is again similar to a query, however, this utilizes WebSockets and dart Streams to provide real-time updates from a server.
219+
Before subscriptions can be performed a global intance of `socketClient` needs to be initialized.
220+
221+
> We are working on moving this into the same `GraphqlProvider` stucture as the http client. Therefore this api might change in the near future.
222+
223+
```dart
224+
socketClient = await SocketClient.connect('ws://coolserver.com/graphql');
225+
```
226+
227+
Once the `socketClient` has been initialized it can be used by the `Subscription` `Widget`
228+
229+
```dart
230+
class _MyHomePageState extends State<MyHomePage> {
231+
@override
232+
Widget build(BuildContext context) {
233+
return Scaffold(
234+
body: Center(
235+
child: Subscription(
236+
operationName,
237+
query,
238+
variables: variables,
239+
builder: ({
240+
bool loading,
241+
dynamic payload,
242+
dynamic error,
243+
}) {
244+
if (payload != null) {
245+
return Text(payload['requestSubscription']['requestData']);
246+
} else {
247+
return Text('Data not found');
248+
}
249+
}
250+
),
251+
)
252+
);
253+
}
254+
}
255+
```
256+
257+
Once the `socketClient` is initialized you could also use it without Flutter.
258+
259+
```dart
260+
final String operationName = "SubscriptionQuery";
261+
final String query = """subscription $operationName(\$requestId: String!) {
262+
requestSubscription(requestId: \$requestId) {
263+
requestData
264+
}
265+
}""";
266+
final dynamic variables = {
267+
'requestId': 'My Request',
268+
};
269+
socketClient
270+
.subscribe(SubscriptionRequest(operationName, query, variables))
271+
.listen(print);
272+
```
273+
204274
### Graphql Consumer
205275

206276
You can always access the client direcly from the `GraphqlProvider` but to make it even easier you can also use the `GraphqlConsumer` widget.
@@ -221,7 +291,7 @@ You can always access the client direcly from the `GraphqlProvider` but to make
221291
...
222292
```
223293

224-
### Offline Cache
294+
### Offline Cache (Experimental)
225295

226296
The in-memory cache can automatically be saved to and restored from offline storage. Setting it up is as easy as wrapping your app with the `CacheProvider` widget.
227297

@@ -248,76 +318,21 @@ class MyApp extends StatelessWidget {
248318
...
249319
```
250320

251-
### Subscriptions (Experimental)
252-
253-
The syntax for subscriptions is again similar to a query, however, this utilizes WebSockets and dart Streams to provide real-time updates from a server.
254-
Before subscriptions can performed the following code is required for initializing the global `socketClient` instance.
255-
256-
```dart
257-
socketClient = await SocketClient.connect('ws://coolserver.com/graphql');
258-
259-
// Example non-flutter usage:
260-
final String operationName = "SubscriptionQuery";
261-
final String query = """subscription $operationName(\$requestId: String!) {
262-
requestSubscription(requestId: \$requestId) {
263-
requestData
264-
}
265-
}""";
266-
final dynamic variables = {
267-
'requestId': 'My Request',
268-
};
269-
socketClient
270-
.subscribe(SubscriptionRequest(operationName, query, variables))
271-
.listen(print);
272-
```
273-
274-
Once the `socketClient` has been initialized it can be used by the `Subscription` `Widget`
275-
276-
```dart
277-
class _MyHomePageState extends State<MyHomePage> {
278-
@override
279-
Widget build(BuildContext context) {
280-
return Scaffold(
281-
body: Center(
282-
child: Subscription(
283-
operationName,
284-
query,
285-
variables: variables,
286-
builder: ({
287-
bool loading,
288-
dynamic payload,
289-
dynamic error,
290-
}) {
291-
if (payload != null) {
292-
return Text(payload['requestSubscription']['requestData']);
293-
} else {
294-
return Text('Data not found');
295-
}
296-
}
297-
),
298-
)
299-
);
300-
}
301-
}
302-
```
303-
304321
## Roadmap
305322

306323
This is currently our roadmap, please feel free to request additions/changes.
307324

308325
| Feature | Progress |
309326
| :---------------------- | :------: |
310-
| Basic queries ||
311-
| Basic mutations ||
312-
| Basic subscriptions | 🔜 |
313-
| Query variables ||
314-
| Mutation variables ||
315-
| Subscription variables | 🔜 |
327+
| Queries ||
328+
| Mutations ||
329+
| Subscriptions ||
316330
| Query polling ||
317-
| In memory caching ||
318-
| Offline caching ||
331+
| In memory cache ||
332+
| Offline cache sync ||
319333
| Optimistic results | 🔜 |
320334
| Client state management | 🔜 |
335+
| Modularity | 🔜 |
321336

322337
## Contributing
323338

pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: graphql_flutter
22
description: A GraphQL client for Flutter.
3-
version: 0.6.0
3+
version: 0.7.0
44
authors:
55
- Eus Dima <[email protected]>
66
- Zino Hofmann <[email protected]>
@@ -11,8 +11,8 @@ dependencies:
1111
sdk: flutter
1212
http: ^0.11.0
1313
path_provider: ^0.4.0
14+
uuid: ^1.0.1
1415
test: ^0.12.0
15-
uuid: 1.0.1
1616

1717
dev_dependencies:
1818
flutter_test:

0 commit comments

Comments
 (0)