mirror of
https://github.com/strapi/strapi.git
synced 2025-12-05 03:21:22 +00:00
Only register writable attributes in input types
This commit is contained in:
parent
1a7f02a19d
commit
d9dd66de4d
@ -1,6 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { inputObjectType, nonNull } = require('nexus');
|
||||
const {
|
||||
contentTypes: { getWritableAttributes },
|
||||
} = require('@strapi/utils');
|
||||
|
||||
module.exports = context => {
|
||||
const { strapi } = context;
|
||||
@ -38,6 +41,9 @@ module.exports = context => {
|
||||
name,
|
||||
|
||||
definition(t) {
|
||||
const writableAttributes = getWritableAttributes(contentType);
|
||||
|
||||
const isWritableAttribute = attributeName => writableAttributes.includes(attributeName);
|
||||
const isFieldEnabled = fieldName => {
|
||||
return extension
|
||||
.shadowCRUD(contentType.uid)
|
||||
@ -45,8 +51,8 @@ module.exports = context => {
|
||||
.hasInputEnabled();
|
||||
};
|
||||
|
||||
const validAttributes = Object.entries(attributes).filter(([attributeName]) =>
|
||||
isFieldEnabled(attributeName)
|
||||
const validAttributes = Object.entries(attributes).filter(
|
||||
([attributeName]) => isWritableAttribute(attributeName) && isFieldEnabled(attributeName)
|
||||
);
|
||||
|
||||
// Add the ID for the component to enable inplace updates
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user