diff --git a/src/index.js b/src/index.js index 6e07a2a..c7d1edc 100644 --- a/src/index.js +++ b/src/index.js @@ -156,10 +156,15 @@ module.exports = { types: { [typeName]: async function({ id }) { let normalFields = fieldNames.map((name) => { - return [ name, async (_, { dlayerKnexTable }) => { - let record = await dlayerKnexTable.load(id); - return record[name]; - }]; + if (name === primaryKey) { + // No point making a trip to the database if all we need is an ID we already have + return [ name, id ]; + } else { + return [ name, async (_, { dlayerKnexTable }) => { + let record = await dlayerKnexTable.load(id); + return record[name]; + }]; + } }); let relationFields = [];