@raynode/graphql-connector-sequelize
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -8,10 +8,9 @@ import { GeneratedModelMapper } from '@raynode/graphql-connector'; | ||
} | ||
export interface SequelizeAttribute { | ||
_autoGenerated?: boolean; | ||
type: DataTypes; | ||
allowNull: boolean; | ||
primaryKey?: boolean; | ||
comment: string; | ||
references?: SequelizeAttributeReference; | ||
export interface SequelizeAttribute extends Sequelize.DefineAttributeColumnOptions { | ||
visible?: boolean; | ||
updateable?: boolean; | ||
createable?: boolean; | ||
type: DataTypes | Sequelize.DataTypeAbstract; | ||
} | ||
export declare type SequelizeAttributes<Keys extends string = string> = Record<Keys, string | SequelizeAttribute>; | ||
export declare type SequelizeAssociationTypes = 'HasOne' | 'HasMany' | 'BelongsTo' | 'BelongsToMany'; | ||
@@ -18,0 +17,0 @@ export interface SequelizeAssociation { |
@@ -12,3 +12,4 @@ "use strict"; | ||
const attribute = rawModel.rawAttributes[name]; | ||
// if(d) console.log(JSON.stringify(attribute, null, 2)) | ||
if (attribute.visible === false) | ||
return; | ||
addAttribute({ | ||
@@ -15,0 +16,0 @@ name, |
{ | ||
"name": "@raynode/graphql-connector-sequelize", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "", | ||
@@ -39,3 +39,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@raynode/graphql-connector": "^0.7.1", | ||
"@raynode/graphql-connector": "^0.7.2", | ||
"@types/lodash": "^4.14.118", | ||
@@ -63,3 +63,3 @@ "@types/sequelize": "^4.27.30", | ||
}, | ||
"gitHead": "e8074965bbf0160a662621d9b524a4b64bf95d80" | ||
"gitHead": "80f42c7de22f3b36a4baa29644e131a25c52d693" | ||
} |
@@ -7,3 +7,2 @@ import { AnyModel, createModelMapper, GeneratedModelMapper, Page } from '@raynode/graphql-connector' | ||
// somehow the sequelize types are really really bad! | ||
export interface SequelizeAttributeReference { | ||
@@ -14,11 +13,15 @@ model: string | ||
export interface SequelizeAttribute { | ||
_autoGenerated?: boolean | ||
type: DataTypes | ||
allowNull: boolean | ||
primaryKey?: boolean | ||
comment: string | ||
references?: SequelizeAttributeReference | ||
export interface SequelizeAttribute extends Sequelize.DefineAttributeColumnOptions { | ||
// should this attribute be represented in the SDL and be handled by graphql-connector (default: true) | ||
visible?: boolean | ||
// should this attribute be in the update mutation (default: true) | ||
updateable?: boolean | ||
// should this attribute be in the create mutation (default: true) | ||
createable?: boolean | ||
// these are correct, but incompatible... these sequelize types... | ||
type: DataTypes | Sequelize.DataTypeAbstract | ||
} | ||
export type SequelizeAttributes<Keys extends string = string> = Record<Keys, string | SequelizeAttribute> | ||
export type SequelizeAssociationTypes = 'HasOne' | 'HasMany' | 'BelongsTo' | 'BelongsToMany' | ||
@@ -59,6 +62,8 @@ | ||
const attribute = rawModel.rawAttributes[name] | ||
// if(d) console.log(JSON.stringify(attribute, null, 2)) | ||
if(attribute.visible === false) | ||
return | ||
addAttribute({ | ||
name, | ||
type: attribute.type, | ||
type: attribute.type as DataTypes, | ||
nonNull: attribute.allowNull === false || attribute.primaryKey === true, | ||
@@ -65,0 +70,0 @@ resolver: instance => instance[name], |
import { pluralize } from 'inflection' | ||
import * as Sequelize from 'sequelize' | ||
import { SequelizeAttribute, SequelizeAttributes } from '../model-mapper' | ||
@@ -19,3 +20,3 @@ const sequelize = new Sequelize({ | ||
const id = { | ||
const id: SequelizeAttribute = { | ||
type: Sequelize.UUID, | ||
@@ -47,3 +48,4 @@ allowNull: false, | ||
title: { type: Sequelize.STRING, allowNull: false }, | ||
}) | ||
UserId: { type: Sequelize.UUID, visible: false }, | ||
} as SequelizeAttributes) | ||
@@ -50,0 +52,0 @@ export const Loop = sequelize.define('Loop', { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
125853
2225