From d9b396821db8e01e6a77f67cf772153361c5cd40 Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Mon, 10 Jun 2019 20:36:12 +0200 Subject: [PATCH] Fix primaryKey not found for custom resolvers --- packages/strapi-plugin-graphql/services/Query.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/strapi-plugin-graphql/services/Query.js b/packages/strapi-plugin-graphql/services/Query.js index d0743605a2..fed49f73b4 100644 --- a/packages/strapi-plugin-graphql/services/Query.js +++ b/packages/strapi-plugin-graphql/services/Query.js @@ -286,14 +286,17 @@ module.exports = { Object.defineProperties(ctx, { query: { value: { - ...this.convertToParams(_.omit(opts, 'where'), model.primaryKey), + ...this.convertToParams( + _.omit(opts, 'where'), + model ? model.primaryKey : 'id' + ), ...this.convertToQuery(opts.where), }, writable: true, configurable: true, }, params: { - value: this.convertToParams(opts, model.primaryKey), + value: this.convertToParams(opts, model ? model.primaryKey : 'id'), writable: true, configurable: true, },