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

Migrate to the Nhost v2 backend #50

Merged
merged 1 commit into from
Jan 28, 2022
Merged

Migrate to the Nhost v2 backend #50

merged 1 commit into from
Jan 28, 2022

Conversation

shyndman
Copy link
Contributor

@shyndman shyndman commented Jan 27, 2022

This release is a work in progress.

There are still a few endpoints that I need to either add or properly test, and more docs to write, but is solid enough that I'm comfortable pushing out a beta version.

Broadly, this release includes support for:

  • Single URL configuration of NhostClients
  • Easier GQL client and link creation
  • Serverless function calls, via NhostClient.functions
  • GraphQL-based storage of file metadata
  • Pre-signed URLs for sharing of protected files Storage.getPresignedUrl
  • Additional image transformation parameters in Storage.downloadImage
  • Dev server scripts/configs for running the examples
  • Improved testability with a new test dev server, HTTP proxy support in
    testing environments, and environment-driven logging

Related to #51

@shyndman shyndman mentioned this pull request Jan 27, 2022
4 tasks
@shyndman shyndman linked an issue Jan 27, 2022 that may be closed by this pull request
4 tasks
@shyndman shyndman force-pushed the v2 branch 8 times, most recently from 828ec5c to a11780b Compare January 28, 2022 23:17
Support for the v2 backend is a work in progress.

There are still a few endpoints that I need to either add or properly
test, AND more docs to write, but is solid enough that I'm comfortable
pushing out a beta version.

Broadly, this release includes support for:
* Single URL configuration of `NhostClient`s
* Easier GQL client and link creation
* Serverless function calls, via `NhostClient.functions`
* GraphQL-based storage of file metadata
* Pre-signed URLs for sharing of protected files
  `Storage.getPresignedUrl`
* Additional image transformation parameters in `Storage.downloadImage`
* Dev server scripts/configs for running the examples
* Improved testability with a new test dev server, HTTP proxy support in
  testing environments, and environment-driven logging
@shyndman shyndman self-assigned this Jan 28, 2022
@shyndman shyndman marked this pull request as ready for review January 28, 2022 23:38
@shyndman shyndman merged commit 1b927b4 into main Jan 28, 2022
@shyndman shyndman deleted the v2 branch January 28, 2022 23:39
// particularly in the ?all=true case, the user should know about it
}

await _clearSession();
return AuthResponse(session: null, user: null);
}

/// Activates a user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shyndman are the confirmations now being handled by nhost directly? For example activation of the account, confirm email change, confirm password change. I see there is an optional redirect now. Is the intention that if not provided then nhost will manage it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pjindal91,

Yes, that's correct. Nhost sends out an email containing a link to an Nhost-managed confirmation endpoint. Upon confirmation, the user will be redirected to the address you've specified (which can be an app/universal link).

If not provided, the user will be redirected to an application default, specified via the AUTH_CLIENT_URL environment variable.

Note that it appears there are some other rules surrounding this. You can't redirect to arbitrary URLs. The logic is here: https://github.com/nhost/hasura-auth/blob/main/src/helpers.ts#L150

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it. Thanks for the explanation @shyndman

@@ -0,0 +1,41 @@
import 'package:http/http.dart' as http;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is dart supported by nhost now in addition to js/ts? How are endpoints specified?

Copy link
Contributor Author

@shyndman shyndman Jan 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, no Dart at the moment, although I'd definitely file a request over at https://github.com/nhost/nhost

Although sparse, the docs here describe how the process works for JS/TS

(It looks like there may be Go support in there as well? I saw something in the code that made me think it, but I haven't tried it out)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it @shyndman, then what is the purpose of this function? I misunderstood as serverless functions that are provided by 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.

This is a client for calling serverless functions.

Maybe I need a better name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah understood. Maybe name could be else but i think documentation could be enough as well. I was looking at it without documentation hence got bit confused.

A question i have is why is it always making a post request? https://github.com/nhost/nhost-dart/pull/50/files/f0d0056b3e295ec7add49a99dcf933156682b0e6#diff-4be4a0d206d165857c3d6c4f69537dd96a82bf1da61223ba714539337db95fe2R34

I believe the serverless functions right now support both get and post. Wouldnt this cause inconsistency between the sdk and the nhost serverless function support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to file it as a feature request? I'll get to it tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I can do that. Also with v2 i dont know if things have changed and now the serverless function routes are only supported for POST. I know previously it used to support POST, GET and possibly DELETE as well. So maybe worth checking with Nhost team if that still is the case.

Also I dont think i need that feature right now, i was just going through the code to understand more about V2 and saw that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, then might sense to have that support here as well for 2 reasons i believe:

  • Consistency in the functionality supported by infrastructure and sdk
  • Based on principle of least surprises, the user would be aware what kind of request is being made instead of automatic post request everytime

Created #55 as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Nhost v2
2 participants