Hi all,
Wanted to share a pre-ADR idea for consideration. This is very nascent and may contain some faulty assumptions!
We have a long-standing gap in our config capabilities where, when we define a waffle flag in the backend (i.e., edx-platform), we have no good way of getting that value up to the micro-frontends. The only way I know of to solve this today is to add the value of the waffle flag into an existing API call the MFE makes, which is somewhat hacky. If you need to send a waffle flag to many MFEs, this can become a lot of work to find appropriate APIs to use.
I was thinking about whether or not we could use the MFE config API to solve this problem, allowing us to atomically update a waffle flag on the backend and have it propagated to the frontend on page load.
Iām making up the details here, but in spirit:
MFE_CONFIG = {
"BASE_URL": "https://name_of_mfe.example.com",
"LANGUAGE_PREFERENCE_COOKIE_NAME": "example-language-preference",
"LOGO_URL": "https://courses.example.com/logo.png"
}
MFE_CONFIG_OVERRIDES = {
"mymfe": {
"LANGUAGE_PREFERENCE_COOKIE_NAME": "mymfe-language-preference",
"LOGO_URL": "https://courses.example.com/mymfe-logo.png",
"waffle_flags": { # This is new!
"ENABLE_MY_THING": "mymfe.enable_my_thing"
}
},
"yourmfe": {
"LANGUAGE_PREFERENCE_COOKIE_NAME": "yourmfe-language-preference",
"LOGO_URL": "https://courses.example.com/yourmfe-logo.png",
},
}
ENABLE_MY_THING
is the key that would arrive in the client, and 'mymfe.enable_my_thing'
is the waffle flag namespace and name. The MFEConfigView.get
handler (edx-platform/lms/djangoapps/mfe_config_api/views.py) would be updated to look for waffle_flags
and add flag values into the response based on the MFEās overrides.
One potential issue here is how we ālookupā a waffle flag by its string name, rather than by using a reference to the actual WaffleFlag instance. I donāt know enough about their guts to know if thatās even possible, but assuming the MFE_CONFIG_OVERRIDES
may be defined in a YAML file, this may hinge on being able to do so.
Thoughts? For reference, the original MFE Config API PR: feat: add mfe config api by MaferMazu Ā· Pull Request #30473 Ā· openedx/edx-platform Ā· GitHub
Attention @mafermazu and the original reviewers: @Alecar @arbrandes @feanil @Felipe @mgmdi