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

feat: add config to request standard object and dependency middleware implementation #8479

Open
3 tasks done
Moumouls opened this issue Mar 12, 2023 · 3 comments · May be fixed by #8480
Open
3 tasks done

feat: add config to request standard object and dependency middleware implementation #8479

Moumouls opened this issue Mar 12, 2023 · 3 comments · May be fixed by #8480
Labels
type:feature New feature or improvement of existing feature

Comments

@Moumouls
Copy link
Member

Moumouls commented Mar 12, 2023

New Feature / Enhancement Checklist

Current Limitation

No way to leverage inversion of control/dependency injection properly for each request

Feature / Enhancement Description

Parse Server is build following Hexagonal software architecture, and originally heavily use inversion of control patterns, that allow parse server to be easily extendable and customizable.

Currently there is no way to add some custom controllers with request granularity to the parse config. Following the Parse Server DNA, developers should be able to modify config per request, mutate config object if needed. Then the config is forwarded to each Parse Server hooks, and even in each Parse Server GraphQL resolvers.

Example Use Case

See the linked PR
#8480

In my company we already use this feature from my fork to implement elegantly custom controllers related to request data (user, keys etc...), and for example a "FeatureFlagController".

Alternatives / Workarounds

No workarounds

3rd Party References

@parse-github-assistant
Copy link

parse-github-assistant bot commented Mar 12, 2023

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@Moumouls Moumouls linked a pull request Mar 12, 2023 that will close this issue
4 tasks
@Moumouls Moumouls added the type:feature New feature or improvement of existing feature label Mar 12, 2023
@dblythy
Copy link
Member

dblythy commented Mar 14, 2023

You can get and set the config at the moment with the global property Parse.Server, which will return the current config.

Is this related to #8448?

@Moumouls
Copy link
Member Author

Not related @dblythy the set and get config is a singleton implementation pattern. With some limitations.

Her it's a inversion of control, dependency injection that allow to modify, overwrite the config for each request just before the request is forwarded to the parse server engine.

This kind of pattern allow:

  • Great testing experience
  • Single source of truth about config extension, modification
  • Config customization per request (allow to adjust,extend, modify the config,, for example a feature flag adapter, depending of the current user, or a header flag)
  • The modified config is then available under the standard config object every where in Parse Server triggres (graphql custom resolvers, hooks, auth adapters, cloud functions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants