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

Restructure Project to Support DI and Nullity #36

Merged
merged 9 commits into from
Nov 13, 2022

Conversation

acupofjose
Copy link
Contributor

@acupofjose acupofjose commented Nov 10, 2022

In reference to: #23, #34, #35.

This pull request implements the major api changes introduced in:

It also introduces some major changes to the Supabase C# library.

  • Client is no longer a singleton, singleton interactions (if desired) are left to the developer to implement.
  • Client supports injection of dependent clients after initialization via property:
    • AuthClient
    • FunctionsClient
    • RealtimeClient
    • PostgrestClient
    • StorageClient
  • SupabaseModel contains no logic but remains for backwards compatibility. (Marked Obsolete)
  • ClientOptions.ShouldInitializeRealtime was removed (no longer auto initialized)
  • ClientOptions now references an ISupabaseSessionHandler which specifies expected functionality for session persistence on Gotrue (replaces ClientOptions.SessionPersistor, ClientOptions.SessionRetriever, and ClientOptions.SessionDestroyer).

@acupofjose acupofjose marked this pull request as draft November 10, 2022 19:38
@acupofjose
Copy link
Contributor Author

@veleek any chance you'd be up to review this one? I appreciated your eyes on realtime-csharp!

Copy link

@veleek veleek left a comment

Choose a reason for hiding this comment

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

Nothing seems obviously broken or anything. Got lots of comments on design and other potential updates to make.

I'm always a very picky code reviewer, so feel free to ignore any of my comments and I won't be upset or anything. Just looking to provide as much input as I can.

Supabase/SupabaseTable.cs Show resolved Hide resolved
Supabase/SupabaseModel.cs Show resolved Hide resolved
Supabase/Interfaces/ISupabaseClient.cs Outdated Show resolved Hide resolved
Supabase/Client.cs Outdated Show resolved Hide resolved
Supabase/SupabaseOptions.cs Outdated Show resolved Hide resolved
Supabase/StatelessClient.cs Outdated Show resolved Hide resolved
Supabase/Client.cs Outdated Show resolved Hide resolved
Supabase/StatelessClient.cs Outdated Show resolved Hide resolved
Supabase/SupabaseFunctions.cs Outdated Show resolved Hide resolved
Supabase/Client.cs Outdated Show resolved Hide resolved
@veleek
Copy link

veleek commented Nov 11, 2022

Also wanted to say "Thanks" for this change. I literally JUST started integrating this into my project and was running into problems with the async initialization and dependency injection stuff. Perfect timing!

@acupofjose
Copy link
Contributor Author

@veleek Thanks for how thorough your review is! It's very much appreciated. DI is not my forte, so I'm trying to my best with the request for it!

I'll need to update the functions client with your suggested change on the URL being set for the whole client as opposed to per method, and that ought to remove the need for the SupabaseFunctions class. I'll get to that sometime tomorrow I suppose!

@acupofjose
Copy link
Contributor Author

Phew. Alright @veleek - I think that's the last commit. Care to lend me your eyes again?

Supabase/Client.cs Outdated Show resolved Hide resolved
Copy link

@veleek veleek left a comment

Choose a reason for hiding this comment

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

You've given me too much power by listening to ALL my suggestions!!! 🤣

Changes look good, just a few more tweaks!

Supabase/Client.cs Show resolved Hide resolved
}
_postgrestClient.Options.Headers = GetAuthHeaders();
_storageClient.Headers = GetAuthHeaders();
_postgrest.Options.Headers = GetAuthHeaders();
Copy link

Choose a reason for hiding this comment

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

_postgrest already has GetHeaders set to call GetAuthHeaders() so I don't think this is necessary. It'll implicitly use the updated auth token for you so you can just remove these two lines.

headers["X-Client-Info"] = Util.GetAssemblyVersion();

if (supabaseKey != null)
Copy link

Choose a reason for hiding this comment

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

Just spitballing here... would it be crazy to move supabaseKey into the Options object.

Supabase/DefaultSupabaseSessionHandler.cs Show resolved Hide resolved
@acupofjose
Copy link
Contributor Author

lol practically all of your suggestions. But to be fair, very good suggestions!

As I said before, thanks so much for your help on this! Nice to have some extra eyes on it.

@acupofjose acupofjose merged commit d2ac5c7 into master Nov 13, 2022
@acupofjose acupofjose deleted the dev/restructure-project-to-support-di branch November 13, 2022 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants