mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
Fix findOne query for GraphQL
This commit is contained in:
parent
3e92b590d3
commit
51b5ea7b3f
@ -19,10 +19,10 @@ module.exports = {
|
||||
* @return Object
|
||||
*/
|
||||
|
||||
convertToParams: params => {
|
||||
convertToParams: (params, primaryKey) => {
|
||||
return Object.keys(params).reduce((acc, current) => {
|
||||
return Object.assign(acc, {
|
||||
[`_${current}`]: params[current],
|
||||
[`${primaryKey === current ? '' : '_'}${current}`]: params[current],
|
||||
});
|
||||
}, {});
|
||||
},
|
||||
@ -260,7 +260,7 @@ module.exports = {
|
||||
Object.defineProperties(ctx, {
|
||||
query: {
|
||||
value: {
|
||||
...this.convertToParams(_.omit(_options, 'where')),
|
||||
...this.convertToParams(_.omit(_options, 'where'), model.primaryKey),
|
||||
..._options.where,
|
||||
// Avoid population.
|
||||
_populate: model.associations.filter(a => !a.dominant && _.isEmpty(a.model)).map(a => a.alias),
|
||||
@ -269,7 +269,7 @@ module.exports = {
|
||||
configurable: true
|
||||
},
|
||||
params: {
|
||||
value: this.convertToParams(this.amountLimiting(_options)),
|
||||
value: this.convertToParams(this.amountLimiting(_options), model.primaryKey),
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user