Skip to content

Commit

Permalink
Merge pull request #9 from gql-dart/master
Browse files Browse the repository at this point in the history
Staying up to date
  • Loading branch information
agent3bood committed Nov 6, 2020
2 parents 70191a8 + 7b1dd8a commit db6cd87
Show file tree
Hide file tree
Showing 23 changed files with 1,575 additions and 210 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
- gql_exec
- gql_link
- gql_dedupe_link
- gql_dio_link
- gql_error_link
- gql_http_link
- gql_websocket_link
Expand Down Expand Up @@ -159,7 +160,7 @@ jobs:
container:
image: google/dart:latest
env:
PACKAGES: "gql,gql_build,gql_code_builder,gql_dedupe_link,gql_exec,gql_http_link,gql_link,gql_pedantic,gql_transform_link,gql_error_link,gql_websocket_link"
PACKAGES: "gql,gql_build,gql_code_builder,gql_dedupe_link,gql_dio_link,gql_exec,gql_http_link,gql_link,gql_pedantic,gql_transform_link,gql_error_link,gql_websocket_link"
PUB_ACCESS_TOKEN: ${{ secrets.PUB_ACCESS_TOKEN }}
PUB_REFRESH_TOKEN: ${{ secrets.PUB_REFRESH_TOKEN }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
image: google/dart:latest
if: github.ref == 'refs/heads/master'
env:
PACKAGES: "gql,gql_build,gql_code_builder,gql_dedupe_link,gql_exec,gql_http_link,gql_link,gql_pedantic,gql_transform_link,gql_error_link,gql_websocket_link"
PACKAGES: "gql,gql_build,gql_code_builder,gql_dedupe_link,gql_dio_link,gql_exec,gql_http_link,gql_link,gql_pedantic,gql_transform_link,gql_error_link,gql_websocket_link"
PUB_ACCESS_TOKEN: ${{ secrets.PUB_ACCESS_TOKEN }}
PUB_REFRESH_TOKEN: ${{ secrets.PUB_REFRESH_TOKEN }}
steps:
Expand Down
464 changes: 262 additions & 202 deletions docs/gql.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions examples/gql_example_dio_link/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Files and directories created by pub
.dart_tool/
.packages
# Remove the following pattern if you wish to check in your lock file
pubspec.lock

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/
1 change: 1 addition & 0 deletions examples/gql_example_dio_link/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A simple command-line application that uses gql_dio_link
32 changes: 32 additions & 0 deletions examples/gql_example_dio_link/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import "package:dio/dio.dart" as dio;
import "package:gql/language.dart" as gql;
import "package:gql_dio_link/gql_dio_link.dart";
import "package:gql_exec/gql_exec.dart";
import "package:gql_link/gql_link.dart";

const query = """{
countries(filter:{currency:{eq:"EGP"}}){
name
}
}""";

const graphqlEndpoint = "https://countries.trevorblades.com/";

void main(List<String> arguments) async {
final client = dio.Dio();

final Link link = DioLink(
graphqlEndpoint,
client: client,
);

final res = await link
.request(Request(
operation: Operation(document: gql.parseString(query)),
))
.first;

final countryName = res.data["countries"][0]["name"] as String;

print("The country that uses EGP as a form of curruncy is ${countryName}");
}
10 changes: 10 additions & 0 deletions examples/gql_example_dio_link/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: gql_example_dio_link
description: A simple example to show gql_dio_link
environment:
sdk: '>=2.7.0 <3.0.0'
dependencies:
dio: ^3.0.9
gql: ^0.12.3
gql_link: ^0.3.0
gql_exec: ^0.2.4
gql_dio_link: ^0.0.4
75 changes: 75 additions & 0 deletions links/gql_dio_link/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
10 changes: 10 additions & 0 deletions links/gql_dio_link/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
channel: stable

project_type: package
3 changes: 3 additions & 0 deletions links/gql_dio_link/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## [0.0.1] - TODO: Add release date.

* TODO: Describe initial release.
21 changes: 21 additions & 0 deletions links/gql_dio_link/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-present, GQL Dart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions links/gql_dio_link/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Similar to [`gql_http_link`](https://pub.dev/packages/gql_http_link), This is a GQL Terminating Link to execute requests via Dio using JSON.

## Usage

A simple usage example:

```dart
import "package:dio/dio.dart";
import "package:gql_link/gql_link.dart";
import "package:gql_dio_link/gql_dio_link.dart";
void main () {
final dio = Dio();
final link = Link.from([
// SomeLink(),
DioLink("/graphql", client: dio),
]);
}
```

## Features and bugs

Please file feature requests and bugs at the [GitHub][tracker].

[tracker]: https://github.com/TarekkMA/gql_dio_link/issues

## Attribution
This code is adapted from [gql_http_link](https://github.com/gql-dart/gql/blob/master/links/gql_http_link/README.md).
1 change: 1 addition & 0 deletions links/gql_dio_link/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:gql_pedantic/analysis_options.yaml
26 changes: 26 additions & 0 deletions links/gql_dio_link/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
See https://github.com/gql-dart/gql/tree/master/examples/gql_example_dio_link

```dart
final client = dio.Dio();
final Link link = DioLink(
graphqlEndpoint,
client: client,
);
final res = await link
.request(Request(
operation: Operation(document: gql.parseString(
"""{
countries(filter:{currency:{eq:"EGP"}}){
name
}
}""",
)),
))
.first;
final countryName = res.data["countries"][0]["name"] as String;
print("The country that uses EGP as a form of curruncy is ${countryName}");
```
4 changes: 4 additions & 0 deletions links/gql_dio_link/lib/gql_dio_link.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library gql_dio_link;

export "src/dio_link.dart";
export "src/exceptions.dart";
Loading

0 comments on commit db6cd87

Please sign in to comment.