Skip to content

feat: allow injection of httpx client #591

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

silentworks
Copy link
Contributor

What kind of change does this PR introduce?

Allow developers to supply their own httpx client

What is the current behavior?

Httpx client isn't very configurable and has limited options available for the developer

What is the new behavior?

Httpx client can now be configured by the developer and be supplied to the Postgrest library

Additional context

Add any other context or screenshots.

@silentworks silentworks requested a review from grdsdev as a code owner May 10, 2025 08:40
@coveralls
Copy link

coveralls commented May 10, 2025

Pull Request Test Coverage Report for Build 15581113055

Details

  • 19 of 27 (70.37%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 95.722%

Changes Missing Coverage Covered Lines Changed/Added Lines %
postgrest/_async/client.py 9 13 69.23%
postgrest/_sync/client.py 9 13 69.23%
Totals Coverage Status
Change from base Build 15569726630: -0.4%
Covered Lines: 1835
Relevant Lines: 1917

💛 - Coveralls

) -> AsyncClient:
if http_client is not None:
http_client.base_url = base_url
http_client.headers = headers
Copy link
Contributor

Choose a reason for hiding this comment

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

should also pass timeout, verify, proxy, here?

Copy link
Contributor Author

@silentworks silentworks May 10, 2025

Choose a reason for hiding this comment

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

I didn't pass those as I don't want them to be override the options for httpx client the developer will pass. The only options we need to maintain are the base_url and headers. The others should be manually configured by the developer if they are passing their own httpx client.

Copy link
Contributor

@grdsdev grdsdev May 12, 2025

Choose a reason for hiding this comment

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

got it, let us at least deprecate the usage of the other params in favor of the httpx client as in https://github.com/supabase/functions-py/pull/201/files#r2083278694

@silentworks silentworks requested a review from grdsdev June 11, 2025 09:24
@grdsdev
Copy link
Contributor

grdsdev commented Jun 11, 2025

@silentworks can you add at least one test case that uses a custom httpx instance?

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.

3 participants