|
|
@@ -140,16 +140,23 @@ export function addGraphQLCustomFields(
|
|
|
`;
|
|
|
}
|
|
|
|
|
|
- if (schema.getType(`Create${entityName}Input`)) {
|
|
|
- if (writeableNonLocalizedFields.length) {
|
|
|
- for (const structCustomField of structCustomFields) {
|
|
|
- customFieldTypeDefs += `
|
|
|
+ const hasCreateInputType = schema.getType(`Create${entityName}Input`);
|
|
|
+ const hasUpdateInputType = schema.getType(`Update${entityName}Input`);
|
|
|
+
|
|
|
+ if ((hasCreateInputType || hasUpdateInputType) && writeableNonLocalizedFields.length) {
|
|
|
+ // Define any Struct input types that are required by
|
|
|
+ // the create and/or update input types.
|
|
|
+ for (const structCustomField of structCustomFields) {
|
|
|
+ customFieldTypeDefs += `
|
|
|
input ${getStructInputName(entityName, structCustomField)} {
|
|
|
${mapToStructFields(structCustomField.fields, wrapListType(getGraphQlInputType(entityName)))}
|
|
|
}
|
|
|
`;
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ if (hasCreateInputType) {
|
|
|
+ if (writeableNonLocalizedFields.length) {
|
|
|
customFieldTypeDefs += `
|
|
|
input Create${entityName}CustomFieldsInput {
|
|
|
${mapToFields(
|
|
|
@@ -172,7 +179,7 @@ export function addGraphQLCustomFields(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (schema.getType(`Update${entityName}Input`)) {
|
|
|
+ if (hasUpdateInputType) {
|
|
|
if (writeableNonLocalizedFields.length) {
|
|
|
customFieldTypeDefs += `
|
|
|
input Update${entityName}CustomFieldsInput {
|