在graphql中如何获得最后3个元素

pmn*_*zar 5 express sequelize.js graphql graphql-js

在graphql.js 中如何从mysql db 表中获取最后3 个created_at 元素?我使用 sequelize.js

像这样:

query: '{
    elements(last:3){ 
        id
    }
}'
Run Code Online (Sandbox Code Playgroud)

这是我的文件 db.js

const Conn = new Sequelize(/*connection config*/);
Conn.define('elements', {
    id: {
        type: Sequelize.STRING(36),
        primaryKey: true,
        allowNull: false
    }
});
export default Conn;
Run Code Online (Sandbox Code Playgroud)

这是我的文件 schema.js

const Query = new GraphQLObjectType({
    name: 'Query',
    description: 'Root query object',
    fields() {
        return {
            elements: {
                type: new GraphQLList(Element),
                args: {
                    id: {
                        type: GraphQLString
                    }
                },
                resolve (root, args) {
                    return Db.models.elements.findAll({ where: args });
                }
            }
        }
    }
});
Run Code Online (Sandbox Code Playgroud)