How to use the webiny-model.DateAttribute function in webiny-model

To help you get started, we’ve selected a few webiny-model examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / webiny-api / src / attributes / convertToGraphQL.js View on Github external
if (entityClass) {
            const entity = new entityClass();

            type = new GraphQLList(
                schema.getType(entity.classId) ||
                    convertModelToType(
                        entity.classId,
                        { type: "entity" },
                        entity.getAttributes(),
                        schema
                    )
            );
        }
    }

    if (attr instanceof attrs.DateAttribute) {
        type = GraphQLString;
        resolve = (entity: Entity) => {
            const attribute = entity.getAttribute(attr.getName());
            if (attribute) {
                const value = attribute.getValue();
                return value instanceof Date ? value.toISOString() : null;
            }
        };
    }

    if (attr instanceof PasswordAttribute) {
        type = GraphQLString;
    }

    if (attr instanceof IdentityAttribute) {
        type = schema.getType("IdentityType");