From 8f5265622fd5c0b359a20840e84cfc3351984e29 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sat, 25 Jan 2020 23:29:46 -0500 Subject: [PATCH] fix: objection.js 2.0 compat fixes --- server/graph/resolvers/page.js | 8 +++----- server/models/pages.js | 8 +++----- server/models/userKeys.js | 2 +- server/models/users.js | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/server/graph/resolvers/page.js b/server/graph/resolvers/page.js index 9f2e56fb..86ef68cd 100644 --- a/server/graph/resolvers/page.js +++ b/server/graph/resolvers/page.js @@ -61,11 +61,9 @@ module.exports = { 'createdAt', 'updatedAt' ]) - .eagerAlgorithm(WIKI.models.Objection.Model.JoinEagerAlgorithm) - .eager('tags(selectTags)', { - selectTags: builder => { - builder.select('tag') - } + .withGraphJoined('tags') + .modifyGraph('tags', builder => { + builder.select('tag') }) .modify(queryBuilder => { if (args.limit) { diff --git a/server/models/pages.js b/server/models/pages.js index a6dc7c19..0f1cf028 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -704,11 +704,9 @@ module.exports = class Page extends Model { ]) .joinRelated('author') .joinRelated('creator') - .eagerAlgorithm(Model.JoinEagerAlgorithm) - .eager('tags(selectTags)', { - selectTags: builder => { - builder.select('tag', 'title') - } + .withGraphJoined('tags') + .modifyGraph('tags', builder => { + builder.select('tag', 'title') }) .where(queryModeID ? { 'pages.id': opts diff --git a/server/models/userKeys.js b/server/models/userKeys.js index 1509a290..9ec43a00 100644 --- a/server/models/userKeys.js +++ b/server/models/userKeys.js @@ -56,7 +56,7 @@ module.exports = class UserKey extends Model { } static async validateToken ({ kind, token }, context) { - const res = await WIKI.models.userKeys.query().findOne({ kind, token }).eager('user') + const res = await WIKI.models.userKeys.query().findOne({ kind, token }).withGraphJoined('user') if (res) { await WIKI.models.userKeys.query().deleteById(res.id) if (moment.utc().isAfter(moment.utc(res.validUntil))) { diff --git a/server/models/users.js b/server/models/users.js index 67f82bc4..7b5e7466 100644 --- a/server/models/users.js +++ b/server/models/users.js @@ -705,7 +705,7 @@ module.exports = class User extends Model { } static async getGuestUser () { - const user = await WIKI.models.users.query().findById(2).eager('groups').modifyEager('groups', builder => { + const user = await WIKI.models.users.query().findById(2).withGraphJoined('groups').modifyGraph('groups', builder => { builder.select('groups.id', 'permissions') }) if (!user) {