-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Migrate to the Nhost v2 backend
- Loading branch information
Showing
205 changed files
with
5,829 additions
and
4,807 deletions.
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,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
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,2 @@ | ||
/// https://github.com/nhost/nhost-dart/#running-the-example-server | ||
const nhostUrl = 'http://localhost:1337'; |
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,2 @@ | ||
/// https://github.com/nhost/nhost-dart/#running-the-example-server | ||
const nhostUrl = 'http://localhost:1337'; |
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 |
---|---|---|
|
@@ -10,11 +10,7 @@ import 'package:graphql_flutter/graphql_flutter.dart'; | |
import 'package:nhost_flutter_auth/nhost_flutter_auth.dart'; | ||
import 'package:nhost_flutter_graphql/nhost_flutter_graphql.dart'; | ||
|
||
// Fill in these values with the Backend and GraphQL URL found on your Nhost | ||
// project page. | ||
|
||
const nhostApiUrl = 'https://backend-5e69d1d7.nhost.app'; | ||
const nhostGraphQLUrl = 'https://hasura-5e69d1d7.nhost.app/v1/graphql'; | ||
import 'config.dart'; | ||
|
||
void main() { | ||
runApp(TodosQuickStartExample()); | ||
|
@@ -26,8 +22,7 @@ class TodosQuickStartExample extends StatelessWidget { | |
// The NhostGraphQLProvider automatically provides connection information | ||
// to `graphql_flutter` widgets in its subtree. | ||
return NhostGraphQLProvider( | ||
nhostClient: NhostClient(baseUrl: nhostApiUrl), | ||
gqlEndpointUrl: nhostGraphQLUrl, | ||
nhostClient: NhostClient(backendUrl: nhostUrl), | ||
child: MaterialApp( | ||
title: 'Nhost.io Todos Quick Start', | ||
debugShowCheckedModeBanner: false, | ||
|
@@ -48,10 +43,10 @@ class App extends StatelessWidget { | |
|
||
Widget widget; | ||
switch (auth.authenticationState) { | ||
case AuthenticationState.loggedIn: | ||
case AuthenticationState.signedIn: | ||
widget = TodosPage(); | ||
break; | ||
case AuthenticationState.loggedOut: | ||
case AuthenticationState.signedOut: | ||
widget = LoginPage(); | ||
break; | ||
default: | ||
|
@@ -219,7 +214,10 @@ class TodoList extends StatelessWidget { | |
|
||
return ListView( | ||
children: [ | ||
for (final todo in todos) TodoTile(todo: todo), | ||
for (final todo in todos) | ||
if (!todo.isCompleted) TodoTile(todo: todo), | ||
for (final todo in todos) | ||
if (todo.isCompleted) TodoTile(todo: todo), | ||
], | ||
); | ||
} | ||
|
@@ -268,7 +266,7 @@ class TodoListActions extends StatelessWidget { | |
children: [ | ||
TextButton( | ||
onPressed: () { | ||
auth.logout(); | ||
auth.signOut(); | ||
}, | ||
child: Text('Logout'), | ||
), | ||
|
@@ -323,8 +321,8 @@ class _LoginPageState extends State<LoginPage> { | |
@override | ||
void initState() { | ||
super.initState(); | ||
emailController = TextEditingController(); | ||
passwordController = TextEditingController(); | ||
emailController = TextEditingController(text: '[email protected]'); | ||
passwordController = TextEditingController(text: 'password-1'); | ||
} | ||
|
||
@override | ||
|
@@ -338,7 +336,7 @@ class _LoginPageState extends State<LoginPage> { | |
final auth = NhostAuthProvider.of(context)!; | ||
|
||
try { | ||
await auth.login( | ||
await auth.signIn( | ||
email: emailController.text, password: passwordController.text); | ||
} on ApiException { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
|
Oops, something went wrong.