File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111
1212import {
1313 BaseTypedCustomFieldConfig ,
14+ CUSTOM_FIELDS_INPUT_TYPE_SUFFIX ,
1415 CustomFieldConfig ,
1516 CustomFields ,
1617 isNonListRelationCustomField ,
@@ -163,7 +164,7 @@ export function addGraphQLCustomFields(
163164
164165 if ( hasCreateInputType ) {
165166 if ( writeableNonLocalizedFields . length ) {
166- const createCustomFieldsInputType = `Create${ entityName } CustomFieldsInput ` ;
167+ const createCustomFieldsInputType = `Create${ entityName } ${ CUSTOM_FIELDS_INPUT_TYPE_SUFFIX } ` ;
167168 if ( ! schema . getType ( createCustomFieldsInputType ) ) {
168169 customFieldTypeDefs += `
169170 input ${ createCustomFieldsInputType } {
@@ -201,7 +202,7 @@ export function addGraphQLCustomFields(
201202
202203 if ( hasUpdateInputType ) {
203204 if ( writeableNonLocalizedFields . length ) {
204- const updateCustomFieldsInputType = `Update${ entityName } CustomFieldsInput ` ;
205+ const updateCustomFieldsInputType = `Update${ entityName } ${ CUSTOM_FIELDS_INPUT_TYPE_SUFFIX } ` ;
205206 if ( ! schema . getType ( updateCustomFieldsInputType ) ) {
206207 customFieldTypeDefs += `
207208 input ${ updateCustomFieldsInputType } {
Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ import {
1919import { UserInputError } from '../../common/error/errors' ;
2020import { Injector } from '../../common/injector' ;
2121import { ConfigService } from '../../config/config.service' ;
22- import { CustomFieldConfig , CustomFields } from '../../config/custom-field/custom-field-types' ;
22+ import {
23+ CUSTOM_FIELDS_INPUT_TYPE_SUFFIX ,
24+ CustomFieldConfig ,
25+ CustomFields ,
26+ } from '../../config/custom-field/custom-field-types' ;
2327import { parseContext } from '../common/parse-context' ;
2428import { internal_getRequestContext , RequestContext } from '../common/request-context' ;
2529import { validateCustomFieldValue } from '../common/validate-custom-field-value' ;
@@ -216,7 +220,7 @@ export class CustomFieldProcessingInterceptor implements NestInterceptor {
216220 return cached ;
217221 }
218222 const map = new Map < string , Set < string > > ( ) ;
219- const suffix = 'CustomFieldsInput' ;
223+ const suffix = CUSTOM_FIELDS_INPUT_TYPE_SUFFIX ;
220224 const entityNames = ( Object . keys ( this . configService . customFields ) as Array < keyof CustomFields > ) . sort (
221225 ( a , b ) => ( b as string ) . length - ( a as string ) . length ,
222226 ) ;
Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ import { RequestContext } from '../../api/common/request-context';
3333import { Injector } from '../../common/injector' ;
3434import { VendureEntity } from '../../entity/base/base.entity' ;
3535
36+ /**
37+ * The suffix of every generated GraphQL input type that carries an entity's custom fields, e.g.
38+ * `UpdateProductCustomFieldsInput`. It is the single source of this naming convention, shared by the
39+ * schema generation (which produces these types) and the custom-field processing interceptor (which
40+ * discovers them). If this changes, both sides change together.
41+ */
42+ export const CUSTOM_FIELDS_INPUT_TYPE_SUFFIX = 'CustomFieldsInput' ;
43+
3644// prettier-ignore
3745export type DefaultValueType < T extends CustomFieldType | StructFieldType > =
3846 T extends 'string' | 'localeString' | 'text' | 'localeText' ? string :
You can’t perform that action at this time.
0 commit comments