-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for the Ferry GraphQL client library #13
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
55a40aa
ci: Add a workflow step that calls build_runner if required
shyndman 67b0813
feat: Add library for the easy creation of Ferry clients
shyndman a34a8ac
chore: Move link transformation example to nhost_gql_links
shyndman 38f1f09
docs: Add nhost_ferry_adapter to top-level README
shyndman a4a9133
fix: Correct links to source in example READMEs
shyndman 1efce55
docs: Add reference to nhost_ferry_adapter across READMEs
shyndman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
# This is a template that is used to produce package-specific workflows | ||
# | ||
# The reason we want package-specific workflows at all is so we can | ||
# | ||
# 1. Limit the workflow to only being triggered on changes to files on the | ||
# package's path, and that of its dependents | ||
# 2. Display a package-specific testing badge (at the time of writing, you can't | ||
# request badges for matrix configurations) | ||
# | ||
# Instantiations of this template are produced by the Melos postbootstrap script | ||
# which can be found in `melos.yaml`. | ||
|
||
name: 'nhost_ferry_adapter tests' | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- main-null-unsafe | ||
pull_request: | ||
branches: | ||
- main | ||
- main-null-unsafe | ||
schedule: | ||
# Run the quality job at 4am every day | ||
- cron: '0 4 * * *' | ||
|
||
env: {} | ||
jobs: | ||
# Ensure that the package meets a suitably high pub.dev score | ||
score-package-quality: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# We test against several Flutter versions | ||
flutter_channel: [stable, beta] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- run: .github/workflows/scripts/make-relative-pubspecs.sh | ||
|
||
- uses: axel-op/dart-package-analyzer@v3 | ||
# Set an id for the current step, so we can reference it later | ||
id: analysis | ||
with: | ||
githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
relativePath: packages/nhost_ferry_adapter | ||
|
||
- name: Require analysis (near) perfection | ||
env: | ||
# "analysis" is the id set above | ||
TOTAL: ${{ steps.analysis.outputs.total }} | ||
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }} | ||
run: | | ||
PERCENTAGE=$((( $TOTAL ) * 100 / ( $TOTAL_MAX - ${MAX_PANA_MISSING_POINTS:-10} ))) | ||
if (( $PERCENTAGE < 100 )) | ||
then | ||
echo "Score to low ($TOTAL/$TOTAL_MAX)." | ||
exit 1 | ||
fi | ||
|
||
# Analyzes, checks formatting, and tests the packages | ||
test-package: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# We test against several Flutter versions | ||
flutter_channel: [stable, beta] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Determine Flutter version | ||
id: flutter-version | ||
uses: shyndman/latest-flutter-version-action@v1.0.5 | ||
with: | ||
channel: ${{ matrix.flutter_channel }} | ||
|
||
- name: Cache Flutter dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: /opt/hostedtoolcache/flutter | ||
key: ${{ runner.OS }}-flutter-install-cache-${{ steps.flutter-version.outputs.version }} | ||
|
||
# Setup the flutter environment | ||
- name: Setup Dart/Flutter (specific channel) | ||
uses: subosito/flutter-action@v1.4.0 | ||
with: | ||
channel: ${{ matrix.flutter_channel }} | ||
|
||
# Get binary dependencies | ||
- name: Install tools | ||
run: | | ||
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH | ||
pub get | ||
pub global activate junitreport | ||
pub global activate melos | ||
|
||
- name: Bootstrap packages | ||
run: melos bootstrap | ||
|
||
- name: Run build_runner if required | ||
run: > | ||
melos exec | ||
--scope=nhost_ferry_adapter | ||
--scope=nhost_ferry_adapter_example | ||
--depends-on=build_runner -- | ||
'pub run build_runner build' | ||
|
||
# Run analysis on all packages | ||
- name: Analyze packages | ||
run: flutter analyze --no-pub --congratulate packages/* packages/*/example | ||
|
||
# Run tests for package in question | ||
- name: Execute tests | ||
run: > | ||
melos exec | ||
--scope=nhost_ferry_adapter | ||
--dir-exists=test -- | ||
'flutter test --no-pub --machine --coverage | tojunit | ||
> test-results.xml' | ||
|
||
# Report test results | ||
- name: Report test results | ||
uses: mikepenz/action-junit-report@v2 | ||
with: | ||
check_name: 'Test results: nhost_ferry_adapter' | ||
require_tests: false | ||
report_paths: "packages/nhost_ferry_adapter/test-results.xml" | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Check if coverage was generated | ||
- name: Check for coverage file | ||
id: check_coverage_exists | ||
uses: andstor/file-existence-action@v1 | ||
with: | ||
files: "packages/nhost_ferry_adapter/coverage/lcov.info" | ||
|
||
# Report coverage | ||
- name: Report coverage | ||
uses: zgosalvez/github-actions-report-lcov@v1 | ||
with: | ||
artifact-name: 'Test coverage for nhost_ferry_adapter' | ||
coverage-files: packages/nhost_ferry_adapter/coverage/lcov.info | ||
working-directory: packages/nhost_ferry_adapter/ | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
if: ${{ github.event_name != 'pull_request' && steps.check_coverage_exists.outputs.files_exists == 'true' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Files and directories created by pub | ||
.dart_tool/ | ||
.packages | ||
|
||
# Omit commiting pubspec.lock for library packages: | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock | ||
pubspec.lock | ||
|
||
# Conventional directory for build outputs | ||
build/ | ||
|
||
# Directory created by dartdoc | ||
doc/api/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2021 Nhost AB | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Nhost Ferry Adapter for Dart | ||
|
||
[![Pub](https://img.shields.io/pub/v/nhost_ferry_adapter)](https://pub.dev/packages/nhost_ferry_adapter) | ||
[![nhost_ferry_adapter tests](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_ferry_adapter.yaml/badge.svg)](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_ferry_adapter.yaml) | ||
|
||
[Nhost](https://nhost.io) integration with the | ||
[ferry](https://pub.dev/packages/graphql) GraphQL client package. | ||
|
||
If you're user of the `graphql` package, take a look at | ||
[nhost_graphql_adapter](https://pub.dev/packages/nhost_graphql_adapter). | ||
|
||
## Getting Started | ||
### Latest Release | ||
|
||
```yaml | ||
dependencies: | ||
nhost_ferry_adapter: ^1.0.0 | ||
``` | ||
|
||
## 🔥 More Dart & Flutter packages from Nhost | ||
|
||
* [nhost_sdk](https://pub.dev/packages/nhost_sdk) | ||
* [nhost_graphql_adapter](https://pub.dev/packages/nhost_graphql_adapter) | ||
* [nhost_ferry_adapter](https://pub.dev/packages/nhost_ferry_adapter) | ||
* [nhost_flutter_graphql](https://pub.dev/packages/nhost_flutter_graphql) | ||
* [nhost_flutter_auth](https://pub.dev/packages/nhost_flutter_auth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Defines a default set of lint rules enforced for | ||
# projects at Google. For details and rationale, | ||
# see https://github.com/dart-lang/pedantic#enabled-lints. | ||
include: package:pedantic/analysis_options.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.ast.gql.dart | ||
*.req.gql.dart | ||
*.data.gql.dart | ||
*.var.gql.dart | ||
*.gql.g.dart | ||
*.gql.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Nhost Ferry Adapter Examples | ||
|
||
Demonstrates the creation and usage of a Ferry client connected to an Nhost | ||
backend. | ||
|
||
For more information on Ferry, check out https://ferrygraphql.com/ | ||
|
||
* [Todo example](https://github.com/nhost/nhost-dart/blob/main/packages/nhost_ferry_adapter/example/lib/todos_example.dart): A simple example that queries the `todos` table created in the [Nhost Quick Start](https://docs.nhost.io/quick-start) | ||
* [GraphQL schema and query files](https://github.com/nhost/nhost-dart/blob/main/packages/nhost_ferry_adapter/example/lib/graphql) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: ../analysis_options.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
targets: | ||
$default: | ||
builders: | ||
gql_build|schema_builder: | ||
enabled: true | ||
options: | ||
schema: nhost_ferry_adapter_example|lib/graphql/schema.graphql | ||
type_overrides: | ||
timestamptz: | ||
name: DateTime | ||
uuid: | ||
name: String | ||
|
||
gql_build|ast_builder: | ||
enabled: true | ||
|
||
gql_build|data_builder: | ||
enabled: true | ||
options: | ||
schema: nhost_ferry_adapter_example|lib/graphql/schema.graphql | ||
type_overrides: | ||
timestamptz: | ||
name: DateTime | ||
uuid: | ||
name: String | ||
|
||
gql_build|var_builder: | ||
enabled: true | ||
options: | ||
schema: nhost_ferry_adapter_example|lib/graphql/schema.graphql | ||
type_overrides: | ||
timestamptz: | ||
name: DateTime | ||
uuid: | ||
name: String | ||
|
||
gql_build|serializer_builder: | ||
enabled: true | ||
options: | ||
schema: nhost_ferry_adapter_example|lib/graphql/schema.graphql | ||
custom_serializers: | ||
- import: 'package:nhost_ferry_adapter/postgres_types.dart' | ||
name: UuidSerializer | ||
- import: 'package:nhost_ferry_adapter/postgres_types.dart' | ||
name: TimestamptzSerializer | ||
type_overrides: | ||
timestamptz: | ||
name: DateTime | ||
uuid: | ||
name: String | ||
|
||
ferry_generator|req_builder: | ||
enabled: true | ||
options: | ||
schema: nhost_ferry_adapter_example|lib/graphql/schema.graphql | ||
type_overrides: | ||
timestamptz: | ||
name: DateTime | ||
uuid: | ||
name: String |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention the requirement to run
build_runner
before this is usable