-
Notifications
You must be signed in to change notification settings - Fork 4
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
Proposal to refactor and simplify the Supabase.Fetcher module #51
Comments
Love the base ideas! I have some feedback regarding point 2. I'm wondering if we should make https://github.com/ex-aws/ex_aws/blob/main/lib/ex_aws/request/req.ex This would also impact point 3 where we could have this abstracted by the behaviour (with_method, with_path, etc are callbacks that can be used by Fetcher to build a request regardless of backend chosen) |
for sure! actually this probably will be the ideal future idea. currently there's a on #54 we can take a look on how it should look like to have this refactor and i can easily extend it to be more generic since the although i would say it isn't worthy to implement new http clients backends for now and only extract the |
I strongly agree with this. |
also fully agree, we can just setup things up for the future and this abstraction will also make other changes more future ready 👍 |
@filipecabaco wdyt? #55 also, could I ask for a general review for open PRs, kinda there's a merge queue since one depends of another, so it will help the review if some more basic ones are merged. |
Changes look good 👍 do have some notes on readability but we can tackle it later or even automate it with credo 👍 |
approved the PR, really awesome change that really feels like a great step forward ❤️ |
what's on your mind? I'm basically using the default options for credo, does supabase have custom credo rules for elixir projects? |
mainly code readability: with into pipe, function extraction, etc small stuff that we can tackle and use credo strict. at supabase no but it's something i want do bring soon as currently we're breaking a lot of rules 😰 again, not for today 😄 |
understandable! |
Chore
Describe the chore
Objective: Enhance the
Supabase.Fetcher
module to provide a higher-level API that seamlessly integrates withSupabase.Client
, reducing redundancy and improving error handling across various Supabase integration libraries.Key Enhancements:
Centralized Error Handling:
Introduce a behaviour,
Supabase.Error
, to standardize error deserialization across different Supabase services. Each service can implement this behaviour to handle its specific error formats. Additionally, implement a unifiedSupabase.Error
struct to encapsulate errors with contextual information such as the request path, arguments, and a semantic error atom.Enhanced Integration with
Supabase.Client
:Refactor
Supabase.Fetcher
to accept aSupabase.Client
struct, automatically applying necessary headers and base URLs. This approach eliminates repetitive code in integration libraries and ensures consistent request construction. Also implement a request builder approach, so we can build the request with in different ways depending on the service using it without coupling the Fetcher directly to these services, so we avoid code duplication.Simplified Usage in Integration Libraries:
With the refactored
Fetcher
, integration libraries likestorage-ex
andpostgrest-ex
can perform API requests without manually managing headers or constructing URLs manually. This streamlines their codebases and ensures consistency across different services.Benefits:
Additional context
This refactor aims to align the Elixir Supabase client with best practices observed in other language implementations within the Supabase ecosystem, promoting a cohesive developer experience across different platforms.
For reference, Supabase's documentation provides insights into error codes and handling mechanisms:
These resources can guide the implementation of the
SupabaseErrorParser
protocol for different services.The text was updated successfully, but these errors were encountered: