-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'length' of undefined #38
Comments
Getting same issue even with 2.30.1 |
Looks like the shape of the data has changed from what this method getModelDirective is expecting. It seems the for (let i = 0; i < model.fields.length; i+=1) {
const field = model.fields[i];
if (field.isId) {
directiveValue.push({ name: '@@id', values: [field] });
}
if (field.isUnique) {
directiveValue.push({
name: '@@unique',
values: [field],
});
}
} example model object{
name: 'User',
isEmbedded: false,
dbName: null,
fields: [
{
name: 'id',
kind: 'scalar',
isList: false,
isRequired: true,
isUnique: false,
isId: true,
isReadOnly: false,
type: 'Int',
hasDefaultValue: true,
default: [Object],
isGenerated: false,
isUpdatedAt: false
},
{
name: 'email',
kind: 'scalar',
isList: false,
isRequired: true,
isUnique: true,
isId: false,
isReadOnly: false,
type: 'String',
hasDefaultValue: false,
isGenerated: false,
isUpdatedAt: false
},
{
name: 'name',
kind: 'scalar',
isList: false,
isRequired: false,
isUnique: false,
isId: false,
isReadOnly: false,
type: 'String',
hasDefaultValue: false,
isGenerated: false,
isUpdatedAt: false
},
{
name: 'profile',
kind: 'object',
isList: false,
isRequired: false,
isUnique: false,
isId: false,
isReadOnly: false,
type: 'Profile',
hasDefaultValue: false,
relationName: 'ProfileToUser',
relationFromFields: [],
relationToFields: [],
relationOnDelete: 'SetNull',
isGenerated: false,
isUpdatedAt: false
}
],
isGenerated: false,
primaryKey: null,
uniqueFields: [],
uniqueIndexes: []
} |
Hello SDK had a breaking change so this will require a new release. Stay tuned, I plan to work on it this weekend. |
Sorry for the delay here. This is fixed in https://github.com/pantharshit00/prisma-docs-generator/releases/tag/v0.5.0 https://www.npmjs.com/package/prisma-docs-generator/v/0.5.0 |
Starting with prisma version 2.29.0 to current (2.30.0);
The following error now appears when generating docs:
TypeError: Cannot read property 'length' of undefined at ModelGenerator.getModelDirective (/api/node_modules/prisma-docs-generator/dist/generator/model.js:196:28) at /api/node_modules/prisma-docs-generator/dist/generator/model.js:522:34 at Array.map (<anonymous>) at ModelGenerator.getModels (/api/node_modules/prisma-docs-generator/dist/generator/model.js:518:38) at ModelGenerator.getData (/api/node_modules/prisma-docs-generator/dist/generator/model.js:530:26) at new ModelGenerator (/api/node_modules/prisma-docs-generator/dist/generator/model.js:35:26) at HTMLPrinter.toHTML (/api/node_modules/prisma-docs-generator/dist/printer/index.js:48:26) at Object.onGenerate (/api/node_modules/prisma-docs-generator/dist/index.js:51:83) at async LineStream.<anonymous> (/api/node_modules/@prisma/generator-helper/dist/generatorHandler.js:33:24)
Reverting back to prisma version 2.28.0 the error no longer appears.
The text was updated successfully, but these errors were encountered: