-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expose Parse Server config in Cloud Code #7869
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
Comments
Thanks for opening this issue!
|
@mtrezza i can suggest another implementation. What about just adding a |
magic will happen here: Line 248 in 42c9543
|
That means config would only be accessible in a request. If config is static per Parse instance and doesn't change per request, why would you tie it to a request? And how would you access config outside of a request? |
For DX purposes. Parse Server internally heavily use dependency injection by passing config during request execution. This is smart, easier for testing purposes and there is no reason to not expose the config through the request object. Also in a multi-tenancy config config/request makes sense. NOTE: for example on the graphql API the full Parse Server context, with config and auth is available in the GraphQL resolver context arg
Not supported in my PR, it could be an additional implementation. But not currently motivated to look into it. I've not seen this use case on my side since I use Parse Server. So it sounds that |
What's the point of adding code to every request route and add tests for each individual route, if exposing the config via
Why would that be an additional implementation, wouldn't that make your PR obsolete? |
@mtrezza I suggested a quick implementation without any tradeoff. This implementation follow dependency injection strategy well know to facilitate tests (like unit test on cloud function etc...) and also flexibility. Feel free to send a PR for the Parse.Config strategy. My PR will not be outdated or useless. Some properties of the config are already used in each request. There is no reason to not extend the request and allow developers to access to the full config through the request interface. |
How so? If config is accessible via Parse, why would it be useful to provide the config additionally in a request? |
Because dependency injection is another way to consume data. I agree that Parse.Config is also useful but it's also another way to consume the config through a singleton. These 2 solutions can easily coexist and make sense. Dependency injection strategy is easier also to use in a multi-tenant app. User will not need to care about which config to get in his cloud function/hooks. |
Why does it make sense for them to co-exist?
Does Parse Server currently support multi-tenancy? |
Sure, one use dependency injection strategy with it's own benefits and the other use the singleton/import strategy with also it's own benefits
It seems that some users started to succeed to use Parse in multi tenancy config, so it make sense to still implement code "multi tenancy friendly" (ie: #7951) |
We don't consider unofficial / hacked-in features. For Parse Server to support multi-tenancy more internal restructuring is needed. Just like there is So far I don't see any benefits for config as part of a request; but I do see downsides, as it requires more code, more maintenance and more tests. We want to reduce code. In every request, the |
I think there is a naming clash between this and https://docs.parseplatform.org/js/guide/#config Perhaps we could have |
🎉 This change has been released in version 5.3.0-alpha.32 |
🎉 This change has been released in version 5.4.0-beta.1 |
🎉 This change has been released in version 5.4.0-alpha.1 |
🎉 This change has been released in version 5.4.0 |
🎉 This change has been released in version 5.4.0 |
New Feature / Enhancement Checklist
Current Limitation
Customization is a key characteristic of Parse Server. There have been scenarios in the past in which developers need to access adapters / controllers of Parse Server, which is done via the server config. The suggested way to access the config is:
That is not a stable reference and may break if server files are refactored.
See:
Feature / Enhancement Description
Expose the server config via an official method, for example:
Example Use Case
Alternatives / Workarounds
n/a
3rd Party References
n/a
The text was updated successfully, but these errors were encountered: