Skip to content
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
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions .github/workflows/test.nhost_ferry_adapter.yaml
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' }}
8 changes: 8 additions & 0 deletions .github/workflows/test.nhost_flutter_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ jobs:
- name: Bootstrap packages
run: melos bootstrap

- name: Run build_runner if required
run: >
melos exec
--scope=nhost_flutter_auth
--scope=nhost_flutter_auth_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
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.nhost_flutter_graphql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ jobs:
- name: Bootstrap packages
run: melos bootstrap

- name: Run build_runner if required
run: >
melos exec
--scope=nhost_flutter_graphql
--scope=nhost_flutter_graphql_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
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.nhost_gql_links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ jobs:
- name: Bootstrap packages
run: melos bootstrap

- name: Run build_runner if required
run: >
melos exec
--scope=nhost_gql_links
--scope=nhost_gql_links_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
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.nhost_graphql_adapter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ jobs:
- name: Bootstrap packages
run: melos bootstrap

- name: Run build_runner if required
run: >
melos exec
--scope=nhost_graphql_adapter
--scope=nhost_graphql_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
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.nhost_sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ jobs:
- name: Bootstrap packages
run: melos bootstrap

- name: Run build_runner if required
run: >
melos exec
--scope=nhost_sdk
--scope=nhost_sdk_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
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.{package}.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ jobs:
- name: Bootstrap packages
run: melos bootstrap

- name: Run build_runner if required
run: >
melos exec
--scope=#{dart_package_name}
--scope=#{dart_package_name}_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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
| [nhost_flutter_auth](packages/nhost_flutter_auth) | Flutter widgets for exposing Nhost Auth state to your app | [![nhost_flutter_auth](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_flutter_auth.yaml/badge.svg)](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_flutter_auth.yaml) [![nhost_flutter_auth Pub](https://img.shields.io/pub/v/nhost_flutter_auth)](https://pub.dev/packages/nhost_flutter_auth) |
| [nhost_flutter_graphql](packages/nhost_flutter_graphql) | Flutter widgets for providing Nhost GraphQL connections, for use with the [graphql_flutter](https://pub.dev/packages/graphql_flutter) package | [![nhost_flutter_graphql](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_flutter_graphql.yaml/badge.svg)](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_flutter_graphql.yaml) [![nhost_flutter_auth Pub](https://img.shields.io/pub/v/nhost_flutter_graphql)](https://pub.dev/packages/nhost_flutter_graphql) |
| [nhost_graphql_adapter](packages/nhost_graphql_adapter) | GraphQL connection setup, for use with the [graphql](https://pub.dev/packages/graphql) package | [![nhost_graphql_adapter](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_graphql_adapter.yaml/badge.svg)](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_graphql_adapter.yaml) [![nhost_graphql_adapter Pub](https://img.shields.io/pub/v/nhost_graphql_adapter)](https://pub.dev/packages/nhost_graphql_adapter) |
| [nhost_ferry_adapter](packages/nhost_ferry_adapter) | Ferry connection setup, for use with the [ferry](https://pub.dev/packages/ferry) package | [![nhost_ferry_adapter](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_ferry_adapter Pub](https://img.shields.io/pub/v/nhost_ferry_adapter)](https://pub.dev/packages/nhost_ferry_adapter) |
| [nhost_gql_links](packages/nhost_gql_links) | (Internal) Library-independent GraphQL link setup | [![nhost_gql_links](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_gql_links.yaml/badge.svg)](https://github.com/nhost/nhost-dart/actions/workflows/test.nhost_gql_links.yaml) [![nhost_gql_links Pub](https://img.shields.io/pub/v/nhost_gql_links)](https://pub.dev/packages/nhost_gql_links) |
13 changes: 13 additions & 0 deletions packages/nhost_ferry_adapter/.gitignore
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.
20 changes: 20 additions & 0 deletions packages/nhost_ferry_adapter/LICENSE
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.
26 changes: 26 additions & 0 deletions packages/nhost_ferry_adapter/README.md
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)
4 changes: 4 additions & 0 deletions packages/nhost_ferry_adapter/analysis_options.yaml
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
6 changes: 6 additions & 0 deletions packages/nhost_ferry_adapter/example/.gitignore
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
9 changes: 9 additions & 0 deletions packages/nhost_ferry_adapter/example/README.md
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
Copy link
Contributor Author

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

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)
1 change: 1 addition & 0 deletions packages/nhost_ferry_adapter/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: ../analysis_options.yaml
60 changes: 60 additions & 0 deletions packages/nhost_ferry_adapter/example/build.yaml
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
Loading