-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
@dbclkclk TypeError: Cannot read properties of undefined (reading 'attributeTypes') #1628
Comments
This is my UserDataSource... import { logger, model, Schema } from "dynamoose"; import { IndexType, Schema as SchemaType } from "dynamoose/dist/Schema"; import { GraphQLError } from "graphql"; import { Condition } from "dynamoose/dist/Condition"; import dynamoDataSource from "../datasources/dynamodb"; export interface User extends AnyItem, Item {} class UserDataSource { private model: Model; private readonly idpIdIndex: string; private readonly emailIndex: string; private readonly firstNameIndex: string; private readonly lastNameIndex: string; constructor(local = false) {
} async create(
} async searchUsers(searchTextInput: string, role: string): Promise<User[]> {
} async getByIdpId(idpId: string): Promise {
} async findByEmail(email: string): Promise { async filterCosmosUsers(users: User[]): Promise<User[]> {
} async update(user: Partial): Promise {
} async getAllByIds(ids: string[]): Promise<any[]> { export default UserDataSource; The following is the function which is called to look up user by IDP Id: export async function getUserByIdpId( throw new Error("Invalid User"); |
Please note, we use Apollo GraphQL Server.... So I have two integration tests... one which goes thru Apollo and the other one directly thru UserDataSource... The latter one never has any issues whatsoever. |
This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days. |
I am running into a weird issue with dynamoose... The stack is as below:
TypeError: Cannot read properties of undefined (reading 'attributeTypes')
The errors happens in the following function of Item.js:
static isDynamoObject(object, recursive) {
function isValid(value) {
if (typeof value === "undefined" || value === null) {
return false;
}
const keys = Object.keys(value);
const key = keys[0];
const nestedResult = typeof value[key] === "object" && !(value[key] instanceof Buffer) && !(value[key] instanceof Uint8Array) ? Array.isArray(value[key]) ? value[key].every((value) => Item.isDynamoObject(value, true)) : Item.isDynamoObject(value[key]) : true;
const { Schema } = require("./Schema");
const attributeType = Schema.attributeTypes.findDynamoDBType(key);
return typeof value === "object" && keys.length === 1 && attributeType && (nestedResult || Object.keys(value[key]).length === 0 || attributeType.isSet);
}
const keys = Object.keys(object);
const values = Object.values(object);
if (keys.length === 0) {
return null;
}
else {
return recursive ? isValid(object) : values.every((value) => isValid(value));
}
}
it returns the following as undefined:
It works for one model but not for other. I am new to TypeScript and Dynamoose but pretty clueless about why it would fail to load this module only in certain situations.
Expecting Schema to be loaded... I wrote an integration test and within the same integration test, it works fine when I query one model by Id, but fails when I try to do the same for other model.
The text was updated successfully, but these errors were encountered: