-
Notifications
You must be signed in to change notification settings - Fork 4
Configuration
Some configuration settings are in the database and some are in a local JSON file. Orthogonally, some are public (visible to the web client) and some are private (visible only to the server). I don't think there's "overriding" of settings: each setting is either searched in the database or in the JSON file.
(See instanceSettings.ts)
A public instance setting is stored in a local JSON file. It can be private or public. The --settings command line flag specifies the filename, which defaults to settings.json. The JSON file has this structure:
{
"particularSetting": "value",
"public": {
"particularSetting": "value"
},
"private": {
"particularSetting": "value"
}
}A setting can be in the root of the object, or nested in the public or private object.
- If code is running on the server:
- If the value of the setting is an object, then the final value of the setting is the union of the public value, private value, root value, and default value (from most to least preferred for individual sub-keys).
- If the value of the setting is not an object, then the final value is taken from the first place it's found: the root object, private object, public object, and the default value.
- Note that these are opposite preferences!
- If the code is running on the client:
- The value for the preference is taken from the public object, otherwise the default value is used.
- Note that there's no merging of objects, and a value in the root object does not seem to be used.
- These show up in the
window.publicInstanceSettingsobject. They are put there at page rendering time inapolloServer.ts.
(See publicSettings.ts)
These settings are stored in the database and are visible to the client. Do not store secrets here. The databasemetadata collection is used. The document has two fields: name, which has the value "publicSettings"; and value, whose value is the object with the settings.
(See databaseSettings.ts)
These settings are stored in the database and are only visible to the server. The databasemetadata collection is used. The document has two fields: name, which has the value "serverSettings"; and value, whose value is the object with the settings.