Read and update configurations

Important

To read and update configurations you need the GraphQL Configuration Access module installed and activated. To use the queries and mutations of this module, admin rights are needed. This means that the user has to be assigned to the oxidadmin-group.

List configurations

To read or update configurations it’s important to know which type the configuration has, you want to modify or read to. Three list queries are available to figure that out. One for module- (moduleSettings), one for theme- (themeSettings) and one for shop-configurations (shopSettings).

Here is one example how to use it:

call to moduleSettings query
 query settings {
     moduleSettings(
         moduleId: "awesomeModule"
     ) {
         name
         type
         supported
     }
 }
moduleSettings query response
 {
     "data": {
         "moduleSettings": [
             {
                 "name": "intSetting",
                 "type": "num",
                 "supported": true
             },
             {
                 "name": "floatSetting",
                 "type": "num",
                 "supported": true
             },
             {
                 "name": "boolSetting",
                 "type": "bool",
                 "supported": true
             },
             {
                 "name": "stringSetting",
                 "type": "str",
                 "supported": true
             },
             {
                 "name": "arraySetting",
                 "type": "arr",
                 "supported": true
             }
         ]
     }
 }

The returned data is showing the name of the setting, the type, to know how to fetch or change the setting and whether the type is supported by the module queries and mutations at all.

Read configurations

If the type is known, you can read the setting by using one of the type separated queries. The name of the setting and in our case the corresponding module is necessary to explicitly select the configuration.

call to moduleSettingBoolean query
 query booleanSetting {
     moduleSettingBoolean(
         name: "booleanSetting",
         moduleId: "awesomeModule"
     ) {
         name
         value
     }
 }
moduleSettingBoolean query response
 {
     "data": {
         "moduleSettingBoolean": {
             "name": "booleanSetting",
             "value": false,
         }
     }
 }

Update configurations

To update a setting, the name, the new value and in our case the module is necessary.

call to moduleSettingBooleanChange query
 mutation changeBooleanSetting {
     moduleSettingBooleanChange(
         name: "booleanSetting",
         value: true
         moduleId: "awesomeModule"
     ) {
         name
         value
     }
 }
moduleSettingBooleanChange query response
 {
     "data": {
         "moduleSettingsBooleanChange": {
             "name": "booleanSetting",
             "value": true,
         }
     }
 }

Important

Pay attention that the types for module/theme/shop-queries or mutations can be different. Also the handling of the values depends on the implementation in the shop. Only the handling of Theme-configurations are currently implemented by the module itself.

List Themes

Use this query to get the list of all themes. You can use filter like title to filter themes by there titles or active to filter themes on basis of the status.

call to themes query
 query themeListFilter {
     themesList (
         filters: {
             title: {
                 contains: "Theme"
             }
             active: {
                 equals: true
             }
         }
     ) {
         id
         title
         version
         description
         active
     }
 }
themes query response
 {
     "data": {
         "themesList": [
             {
                 "id": "apex",
                 "title": "APEX Theme",
                 "version": "1.3.0",
                 "description": "APEX - Bootstrap 5 TWIG Theme",
                 "active": true
             },
             {
                 "id": "wave",
                 "title": "Wave Theme",
                 "version": "3.0.1",
                 "description": "Wave is OXID`s official responsive theme based on the CSS framework Bootstrap 4.",
                 "active": true
             }
         ]
     }
 }

Switch Theme

In order to activate a theme by a given ID pass themeId as identifier. If errors during the activation process occur, they will be raised and shown.

call to switchTheme query
 mutation switchTheme{
     switchTheme(themeId: "apex")
 }

List Modules

Use this query to get the list of all modules. You can use filter like title to filter themes by there titles or active to filter modules on basis of the status.

call to modules query
 query modulesList {
     modules(
         filters: {
             title: {
                 contains: "GraphQL"
             }
             active: {
                 equals: true
             }
         }
     ) {
         id
         version
         title
         description
         thumbnail
         author
         url
         email
         active
     }
 }
modules query response
 {
     "data": {
         "modules": [
             {
                 "id": "oe_graphql_base",
                 "version": "9.0.0",
                 "title": "GraphQL Base",
                 "description": "<span>OXID GraphQL API Framework</span>",
                 "thumbnail": "logo.png",
                 "author": "OXID eSales",
                 "url": "www.oxid-esales.com",
                 "email": "[email protected]",
                 "active": true
             },
             {
                 "id": "oe_graphql_storefront",
                 "version": "3.0.0",
                 "title": "GraphQL Storefront",
                 "description": "OXID GraphQL Storefront",
                 "thumbnail": "logo.png",
                 "author": "OXID eSales",
                 "url": "https://github.com/OXID-eSales/graphql-storefront-module",
                 "email": "[email protected]",
                 "active": true
             }
         ]
     }
 }

Activate/Deactivate Module

In order to de/activate a module by a given module id as moduleId, you will receive response as Bool value if the module was de/activated. Otherwise you will receive an error message.

call to activateModule query
 mutation activateModule{
     activateModule(moduleId: "awesomeModule")
 }
activateModule query response
 {
     "data": {
         "activateModule": true
     }
 }

Important

Some modules can’t be deactivated as they are listed in the module_blocklist.yaml.` This yaml-file contains a list of modules which are necessary to handle configurations or de/activate modules via GraphQL. Modules like oe_graphql_base and oe_graphql_configuration_access are listed there.