Config Object Tree
Only schema
is mandatory.
let config = {
schema: printSchema(schema),
uploadRoot: '/var/www/site.com/public/stc', // String
exclude: ['paymentType', 'invoiceType'], // Array of String
rules: {
[GraphQL Type name]: {
label: 'Categories', // String
uploadPath: 'product', // String
listHeader: {
id: ['id'], // Array of String
title: ['description'] // Array of String
},
resolvers: {
find: {
resolver: 'categories.find' // String
},
create: {
resolver: 'categories.create' // String
allowed: true // Boolean, by default true
},
update: {
resolver: 'categories.update' // String
},
remove: {
allowed: false // Boolean
}
},
fields: {
[field_name]: {
label: 'custom field name to show in UI', // String
inputControl: 'input', // String
inputType: 'file', // String
list: {
label: 'title' // String
}
disabled: false, //Boolean, by default false
exclude: false //Boolean, by default false
}
}
}
}
}
Props definition:
- schema - your printed schema [required]
- uploadRoot - full path to your public folder
- exclude - GraphQL Types which you don't want to show in CMS
- rules - rules object is a tree with rules for each or any GraphQL Types. CMS in addition will use the same order for side menu and fields in the view page as you will provide in this object
- [GraphQL Type name] - GraphQL Type name by default will be used as name for side menu
- label - custom side menu name
- uploadPath - custom folder where to upload files for this type
- listHeader - data from this fields will be used to show on the first column [id] and second [title] on list page. You can provide couple of fields for each column so it will shows as 'String' + ' | ' + 'String'
- id - fields for first column
- title - fields for second column
- resolvers - if you don't want to use the naming pattern you need to provide Query's and Mutation's method name for each GraphQL Type
- [find, create, update, remove]
- resolver - GraphQL Query or Mutation method name
- allowed - if you don't want to provide some method to client side you can depreciate it for any action besides 'find'
- [find, create, update, remove]
- fields - fields of current GraphQL Type
- [field_name]
- label -
- inputControl - can be 'input' or 'textarea'
- inputType - type for 'input', file, number, text, etc.
- list.label - name of property, wich will be used to show in dropdown menu with options
- disabled - disabled field editing
- exclude - don't render this field in CMS, never exclude field '_id' or 'id'
- [field_name]
- [GraphQL Type name] - GraphQL Type name by default will be used as name for side menu