Skip to content

feat: add http client from Symfony to meilisearch factory if present #5

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

Merged

Conversation

daFish
Copy link
Contributor

@daFish daFish commented Mar 18, 2025

This change adds a new configuration to specify an HTTP client from the container if present. This helps mocking requests in tests.

Bonus point: the initial request is also shown in the web debug toolbar.

@daFish daFish changed the title feat: add http client from Symfony to meilisearch if present feat: add http client from Symfony to meilisearch factory if present Mar 18, 2025
@daFish daFish force-pushed the feat/configurable-http-client branch from 0ac6aa9 to 8fb8871 Compare March 18, 2025 13:42
@daFish
Copy link
Contributor Author

daFish commented Mar 18, 2025

Not sure why the tests are failing. I haven't touched them yet. 🤔

@daFish daFish force-pushed the feat/configurable-http-client branch 3 times, most recently from 0735606 to c9c09d4 Compare March 18, 2025 13:50
@AlexandrePetrone
Copy link
Member

Thanks again for your contribution !

However, adding this to the http_client configuration bothers me a bit, as this option will only be applicable to Meilisearch.
We could instead inject the http_client service directly into the MeilisearchFactory, which would still allow mocking for tests.
Do you see a use case where it would be interesting to pass a custom http_client ?

@daFish
Copy link
Contributor Author

daFish commented Mar 18, 2025

Hey @AlexandrePetrone,

I was inspired by how the official Meilisearch bundle handles this (ref: meilisearch/meilisearch-symfony#359). Speaking of the configuration, I also think the place is not ideal and share your sentiment.

Let's inject the client directly and make it configurable in the future (if needed). WDYT?

@daFish daFish force-pushed the feat/configurable-http-client branch from c9c09d4 to 2768c2a Compare March 18, 2025 17:29
@daFish daFish marked this pull request as ready for review March 18, 2025 17:30
@daFish
Copy link
Contributor Author

daFish commented Mar 18, 2025

Changes done. Testing this is almost impossible as the created Meilisearch client does not expose any properties which can be asserted. However, creating a client in a test with the passed argument should be enough if it doesn't result in an exception. 😅

@daFish daFish force-pushed the feat/configurable-http-client branch from 2768c2a to bf748fa Compare March 18, 2025 17:48
Copy link
Member

@julienj julienj left a comment

Choose a reason for hiding this comment

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

Thank you, @daFish . After this last point, I suggest merging. For tests in Symfony 7.3-dev, we should handle that in another PR, as it's not related to this change.

@daFish
Copy link
Contributor Author

daFish commented Mar 18, 2025

Thank you, @daFish . After this last point, I suggest merging. For tests in Symfony 7.3-dev, we should handle that in another PR, as it's not related to this change.

Should be fixed upstream by symfony/symfony#60001.

@daFish daFish force-pushed the feat/configurable-http-client branch from bf748fa to 5d48716 Compare March 18, 2025 19:07
@AlexandrePetrone AlexandrePetrone merged commit a385702 into Mezcalito:0.x Mar 19, 2025
16 of 20 checks passed
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy