API Reference
The migrateDB
method takes the three arguments, listed below.
config
: Knex database configuration options.schemaText
: GraphQL schema text.options
:dbSchemaName
(default:'public'
): table schema:<schemaName>.<tableName>
.dbTablePrefix
(default:''
): table name prefix:<prefix><tableName>
.dbColumnPrefix
(default:''
): column name prefix:<prefix><columnName>
.updateComments
(default:false
): by default,migrateDB
will not create or update comments on table and columns.scalarMap
(default:undefined
): Custom Scalar mappingmapListToJson
(default:true
): Map scalar/enum lists to json column type by default.plugins
(default:[]
): List of graphql-migrations plugins which describes queries that can be executed during migrations.debug
(default:false
): displays debugging informations and SQL queries.removeDirectivesFromSchema
: (default:true
): Strips all directives from schema before processing.operationFilter
: Filter out database operations that we don't want.
#
Table and Column CommentsWhen updateComments
is set to true
it will automatically create/update table and column comments.
Table / column comments are type or field description parsed from the model schema.
The parsing logic takes care of stripping off all annotations leaving only business related comments.
The below model:
Execution with the updateComments
options set to true, as shown below
Will create / update the note
table comments as shown below:
NOTE: This options may not be supported by some database.
#
Scalar MappingThis option is a function used to specify custom Scalar mapping.
It takes three arguments (field: GraphQLField, fieldType: GraphQLScalarType, dbAnnotation: any)
, depending on the field type you could return the TableColumnTypeDescriptor
:
For example, if you want a custom CustomDate
scalar to be have a date
type in the database:
A good example of this function is the default scalar type to database column function, that Graphback uses to convert scalar types based on certain creteria.