From bdd8def0494586aac0c3f78ba332cbcdeb4d481e Mon Sep 17 00:00:00 2001 From: Mick Hansen Date: Sun, 25 Feb 2018 17:24:20 +0100 Subject: [PATCH] dont mutate args object --- src/relay.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/relay.js b/src/relay.js index 285a8d30..961c4793 100644 --- a/src/relay.js +++ b/src/relay.js @@ -217,15 +217,12 @@ export function sequelizeConnection({ if (args.first || args.last) { options.limit = parseInt(args.first || args.last, 10); } - if (!args.orderBy) { - args.orderBy = [ - [model.primaryKeyAttribute, 'ASC'] - ]; - } else if (orderByEnum && typeof args.orderBy === 'string') { - args.orderBy = [orderByEnum._nameLookup[args.orderBy].value]; + + let orderBy = args.orderBy || [[model.primaryKeyAttribute, 'ASC']]; + if (orderByEnum && typeof orderBy === 'string') { + orderBy = [orderByEnum._nameLookup[args.orderBy].value]; } - let orderBy = args.orderBy; let orderAttribute = orderByAttribute(orderBy[0][0], { source: info.source, args,