prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
675 stars 66 forks source link

Configuration System #297

Open jasonkuhrt opened 4 years ago

jasonkuhrt commented 4 years ago

What

about hierarchy

app.settings.<component>.*
app.settings.plugins.<plugin>.*
app.settings.logger.*
app.settings.server.*
app.settings.db.*
app.settings.plugins.prisma.*

Sometimes duplicated read/write fields under different paths might be nice. Take the experiments system for example:

app.settings.<component>.experiments.*
app.settings.experiments.<component>.*

Basically When something could be distributed or centralized, we should do both so that the user doesn't have to remember.

Related

Places where need for config has come up:

Weakky commented 4 years ago

A few thoughts:

app.settings.plugins.prisma.crud.relations.createable = false

I find this quite terrible 😢. As much as I understand the reasoning for considering the approach, the level of nesting is just too much if we ever get there. I'd rather have a nested object..

to keep the mental model simple, app.settings should make its data readable in plain form:

We currently use the approach of having app.settings being both a "reader" and a "writer". This raised the drawback of having the function prototype in the autocomplete of app.settings. We could simplify things by having app.settings.set({ ... }) and app.settings.get().*. It's not very elegant, but also still keeps "the mental model simple"

jasonkuhrt commented 4 years ago

Take inspiration from https://fastapi.tiangolo.com/advanced/settings/