@payloadcms/graphql 3.24.0-canary.4c8cafd → 3.24.0-canary.5891112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,8 +15,9 @@ type BuildMutationInputTypeArgs = {
15
15
  forceNullable?: boolean;
16
16
  graphqlResult: GraphQLInfo;
17
17
  name: string;
18
+ parentIsLocalized: boolean;
18
19
  parentName: string;
19
20
  };
20
- export declare function buildMutationInputType({ name, config, fields, forceNullable, graphqlResult, parentName, }: BuildMutationInputTypeArgs): GraphQLInputObjectType | null;
21
+ export declare function buildMutationInputType({ name, config, fields, forceNullable, graphqlResult, parentIsLocalized, parentName, }: BuildMutationInputTypeArgs): GraphQLInputObjectType | null;
21
22
  export {};
22
23
  //# sourceMappingURL=buildMutationInputType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildMutationInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildMutationInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAe,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EASX,yBAAyB,EACzB,eAAe,EAMhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAIL,sBAAsB,EAKvB,MAAM,SAAS,CAAA;AAUhB,QAAA,MAAM,YAAY;;;CAGjB,CAAA;AAED,eAAO,MAAM,mBAAmB,SACxB,MAAM,OAAO,YAAY,cACnB,yBAAyB,KACpC,iBAUF,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACxC,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,aAAqB,EACrB,aAAa,EACb,UAAU,GACX,EAAE,0BAA0B,GAAG,sBAAsB,GAAG,IAAI,CAyT5D"}
1
+ {"version":3,"file":"buildMutationInputType.d.ts","sourceRoot":"","sources":["../../src/schema/buildMutationInputType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAe,MAAM,SAAS,CAAA;AACtF,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EASX,yBAAyB,EACzB,eAAe,EAMhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAIL,sBAAsB,EAKvB,MAAM,SAAS,CAAA;AAUhB,QAAA,MAAM,YAAY;;;CAGjB,CAAA;AAED,eAAO,MAAM,mBAAmB,SACxB,MAAM,OAAO,YAAY,cACnB,yBAAyB,KACpC,iBAUF,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACxC,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,aAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,EAAE,0BAA0B,GAAG,sBAAsB,GAAG,IAAI,CAmV5D"}
@@ -17,7 +17,7 @@ export const getCollectionIDType = (type, collection)=>{
17
17
  }
18
18
  return idFieldTypes[idField.type];
19
19
  };
20
- export function buildMutationInputType({ name, config, fields, forceNullable = false, graphqlResult, parentName }) {
20
+ export function buildMutationInputType({ name, config, fields, forceNullable = false, graphqlResult, parentIsLocalized, parentName }) {
21
21
  const fieldToSchemaMap = {
22
22
  array: (inputObjectTypeConfig, field)=>{
23
23
  const fullName = combineParentName(parentName, toWords(field.name, true));
@@ -26,12 +26,18 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
26
26
  config,
27
27
  fields: field.fields,
28
28
  graphqlResult,
29
+ parentIsLocalized: parentIsLocalized || field.localized,
29
30
  parentName: fullName
30
31
  });
31
32
  if (!type) {
32
33
  return inputObjectTypeConfig;
33
34
  }
34
- type = new GraphQLList(withNullableType(field, type, forceNullable));
35
+ type = new GraphQLList(withNullableType({
36
+ type,
37
+ field,
38
+ forceNullable,
39
+ parentIsLocalized
40
+ }));
35
41
  return {
36
42
  ...inputObjectTypeConfig,
37
43
  [field.name]: {
@@ -54,7 +60,12 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
54
60
  code: (inputObjectTypeConfig, field)=>({
55
61
  ...inputObjectTypeConfig,
56
62
  [field.name]: {
57
- type: withNullableType(field, GraphQLString, forceNullable)
63
+ type: withNullableType({
64
+ type: GraphQLString,
65
+ field,
66
+ forceNullable,
67
+ parentIsLocalized
68
+ })
58
69
  }
59
70
  }),
60
71
  collapsible: (inputObjectTypeConfig, field)=>field.fields.reduce((acc, subField)=>{
@@ -67,13 +78,23 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
67
78
  date: (inputObjectTypeConfig, field)=>({
68
79
  ...inputObjectTypeConfig,
69
80
  [field.name]: {
70
- type: withNullableType(field, GraphQLString, forceNullable)
81
+ type: withNullableType({
82
+ type: GraphQLString,
83
+ field,
84
+ forceNullable,
85
+ parentIsLocalized
86
+ })
71
87
  }
72
88
  }),
73
89
  email: (inputObjectTypeConfig, field)=>({
74
90
  ...inputObjectTypeConfig,
75
91
  [field.name]: {
76
- type: withNullableType(field, GraphQLString, forceNullable)
92
+ type: withNullableType({
93
+ type: GraphQLString,
94
+ field,
95
+ forceNullable,
96
+ parentIsLocalized
97
+ })
77
98
  }
78
99
  }),
79
100
  group: (inputObjectTypeConfig, field)=>{
@@ -84,6 +105,7 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
84
105
  config,
85
106
  fields: field.fields,
86
107
  graphqlResult,
108
+ parentIsLocalized: parentIsLocalized || field.localized,
87
109
  parentName: fullName
88
110
  });
89
111
  if (!type) {
@@ -102,7 +124,12 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
102
124
  json: (inputObjectTypeConfig, field)=>({
103
125
  ...inputObjectTypeConfig,
104
126
  [field.name]: {
105
- type: withNullableType(field, GraphQLJSON, forceNullable)
127
+ type: withNullableType({
128
+ type: GraphQLJSON,
129
+ field,
130
+ forceNullable,
131
+ parentIsLocalized
132
+ })
106
133
  }
107
134
  }),
108
135
  number: (inputObjectTypeConfig, field)=>{
@@ -110,20 +137,35 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
110
137
  return {
111
138
  ...inputObjectTypeConfig,
112
139
  [field.name]: {
113
- type: withNullableType(field, field.hasMany === true ? new GraphQLList(type) : type, forceNullable)
140
+ type: withNullableType({
141
+ type: field.hasMany === true ? new GraphQLList(type) : type,
142
+ field,
143
+ forceNullable,
144
+ parentIsLocalized
145
+ })
114
146
  }
115
147
  };
116
148
  },
117
149
  point: (inputObjectTypeConfig, field)=>({
118
150
  ...inputObjectTypeConfig,
119
151
  [field.name]: {
120
- type: withNullableType(field, new GraphQLList(GraphQLFloat), forceNullable)
152
+ type: withNullableType({
153
+ type: new GraphQLList(GraphQLFloat),
154
+ field,
155
+ forceNullable,
156
+ parentIsLocalized
157
+ })
121
158
  }
122
159
  }),
123
160
  radio: (inputObjectTypeConfig, field)=>({
124
161
  ...inputObjectTypeConfig,
125
162
  [field.name]: {
126
- type: withNullableType(field, GraphQLString, forceNullable)
163
+ type: withNullableType({
164
+ type: GraphQLString,
165
+ field,
166
+ forceNullable,
167
+ parentIsLocalized
168
+ })
127
169
  }
128
170
  }),
129
171
  relationship: (inputObjectTypeConfig, field)=>{
@@ -163,7 +205,12 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
163
205
  richText: (inputObjectTypeConfig, field)=>({
164
206
  ...inputObjectTypeConfig,
165
207
  [field.name]: {
166
- type: withNullableType(field, GraphQLJSON, forceNullable)
208
+ type: withNullableType({
209
+ type: GraphQLJSON,
210
+ field,
211
+ forceNullable,
212
+ parentIsLocalized
213
+ })
167
214
  }
168
215
  }),
169
216
  row: (inputObjectTypeConfig, field)=>field.fields.reduce((acc, subField)=>{
@@ -195,7 +242,12 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
195
242
  }, {})
196
243
  });
197
244
  type = field.hasMany ? new GraphQLList(type) : type;
198
- type = withNullableType(field, type, forceNullable);
245
+ type = withNullableType({
246
+ type,
247
+ field,
248
+ forceNullable,
249
+ parentIsLocalized
250
+ });
199
251
  return {
200
252
  ...inputObjectTypeConfig,
201
253
  [field.name]: {
@@ -213,6 +265,7 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
213
265
  config,
214
266
  fields: tab.fields,
215
267
  graphqlResult,
268
+ parentIsLocalized: parentIsLocalized || tab.localized,
216
269
  parentName: fullName
217
270
  });
218
271
  if (!type) {
@@ -243,13 +296,23 @@ export function buildMutationInputType({ name, config, fields, forceNullable = f
243
296
  text: (inputObjectTypeConfig, field)=>({
244
297
  ...inputObjectTypeConfig,
245
298
  [field.name]: {
246
- type: withNullableType(field, field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString, forceNullable)
299
+ type: withNullableType({
300
+ type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,
301
+ field,
302
+ forceNullable,
303
+ parentIsLocalized
304
+ })
247
305
  }
248
306
  }),
249
307
  textarea: (inputObjectTypeConfig, field)=>({
250
308
  ...inputObjectTypeConfig,
251
309
  [field.name]: {
252
- type: withNullableType(field, GraphQLString, forceNullable)
310
+ type: withNullableType({
311
+ type: GraphQLString,
312
+ field,
313
+ forceNullable,
314
+ parentIsLocalized
315
+ })
253
316
  }
254
317
  }),
255
318
  upload: (inputObjectTypeConfig, field)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType(field, type, forceNullable))\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type },\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLJSON, forceNullable) },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n field.hasMany === true ? new GraphQLList(type) : type,\n forceNullable,\n ),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, new GraphQLList(GraphQLFloat), forceNullable) },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLJSON, forceNullable) },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n field.fields.reduce((acc, subField: Field) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n })\n\n type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType(field, type, forceNullable)\n\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n graphqlResult,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return {\n ...acc,\n ...tab.fields.reduce((subFieldSchema, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(subFieldSchema, subField)\n }\n return subFieldSchema\n }, acc),\n }\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType(\n field,\n field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n forceNullable,\n ),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n\n const fieldSchemas = fields.reduce((inputObjectTypeConfig, field) => {\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return inputObjectTypeConfig\n }\n\n const schema = fieldSchema(inputObjectTypeConfig, field)\n if (Object.keys(schema).length === 0) {\n return inputObjectTypeConfig\n }\n\n return {\n ...inputObjectTypeConfig,\n ...fieldSchema(inputObjectTypeConfig, field),\n }\n }, {})\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","idFieldTypes","number","text","getCollectionIDType","type","collection","idField","fields","find","field","name","buildMutationInputType","config","forceNullable","graphqlResult","parentName","fieldToSchemaMap","array","inputObjectTypeConfig","fullName","blocks","checkbox","code","collapsible","reduce","acc","subField","addSubField","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","tab","subFieldSchema","textarea","upload","fieldName","fieldSchemas","fieldSchema","schema","Object","keys","length"],"mappings":"AA4BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SAASC,6BAA6B,QAAQ,gDAA+C;AAC7F,SAASC,gBAAgB,QAAQ,wBAAuB;AAExD,MAAMC,eAAe;IACnBC,QAAQf;IACRgB,MAAMb;AACR;AAEA,OAAO,MAAMc,sBAAsB,CACjCC,MACAC;IAEA,MAAMC,UAAUhB,sBAAsBe,WAAWE,MAAM,EAAEC,IAAI,CAC3D,CAACC,QAAUjB,iBAAiBiB,UAAUA,MAAMC,IAAI,KAAK;IAGvD,IAAI,CAACJ,SAAS;QACZ,OAAON,YAA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;QAChCyB,MAAM,CAAC,QAAQ,EAAE8C,UAAU,KAAK,CAAC;QACjCjD,QAAQkD;IACV;AACF"}
1
+ {"version":3,"sources":["../../src/schema/buildMutationInputType.ts"],"sourcesContent":["import type { GraphQLInputFieldConfig, GraphQLScalarType, GraphQLType } from 'graphql'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n CollapsibleField,\n DateField,\n EmailField,\n Field,\n GraphQLInfo,\n GroupField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RichTextField,\n RowField,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SelectField,\n TabsField,\n TextareaField,\n TextField,\n UploadField,\n} from 'payload'\n\nimport {\n GraphQLBoolean,\n GraphQLEnumType,\n GraphQLFloat,\n GraphQLInputObjectType,\n GraphQLInt,\n GraphQLList,\n GraphQLNonNull,\n GraphQLString,\n} from 'graphql'\nimport { flattenTopLevelFields, toWords } from 'payload'\nimport { fieldAffectsData, optionIsObject, tabHasName } from 'payload/shared'\n\nimport { GraphQLJSON } from '../packages/graphql-type-json/index.js'\nimport { combineParentName } from '../utilities/combineParentName.js'\nimport { formatName } from '../utilities/formatName.js'\nimport { groupOrTabHasRequiredSubfield } from '../utilities/groupOrTabHasRequiredSubfield.js'\nimport { withNullableType } from './withNullableType.js'\n\nconst idFieldTypes = {\n number: GraphQLInt,\n text: GraphQLString,\n}\n\nexport const getCollectionIDType = (\n type: keyof typeof idFieldTypes,\n collection: SanitizedCollectionConfig,\n): GraphQLScalarType => {\n const idField = flattenTopLevelFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n if (!idField) {\n return idFieldTypes[type]\n }\n\n return idFieldTypes[idField.type]\n}\n\nexport type InputObjectTypeConfig = {\n [path: string]: GraphQLInputFieldConfig\n}\n\ntype BuildMutationInputTypeArgs = {\n config: SanitizedConfig\n fields: Field[]\n forceNullable?: boolean\n graphqlResult: GraphQLInfo\n name: string\n parentIsLocalized: boolean\n parentName: string\n}\n\nexport function buildMutationInputType({\n name,\n config,\n fields,\n forceNullable = false,\n graphqlResult,\n parentIsLocalized,\n parentName,\n}: BuildMutationInputTypeArgs): GraphQLInputObjectType | null {\n const fieldToSchemaMap = {\n array: (inputObjectTypeConfig: InputObjectTypeConfig, field: ArrayField) => {\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLList<GraphQLType> | GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n type = new GraphQLList(withNullableType({ type, field, forceNullable, parentIsLocalized }))\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type },\n }\n },\n blocks: (inputObjectTypeConfig: InputObjectTypeConfig, field: BlocksField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: GraphQLJSON },\n }),\n checkbox: (inputObjectTypeConfig: InputObjectTypeConfig, field: CheckboxField) => ({\n ...inputObjectTypeConfig,\n [field.name]: { type: GraphQLBoolean },\n }),\n code: (inputObjectTypeConfig: InputObjectTypeConfig, field: CodeField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>\n field.fields.reduce((acc, subField: CollapsibleField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n email: (inputObjectTypeConfig: InputObjectTypeConfig, field: EmailField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n group: (inputObjectTypeConfig: InputObjectTypeConfig, field: GroupField) => {\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n const fullName = combineParentName(parentName, toWords(field.name, true))\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: field.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return inputObjectTypeConfig\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type },\n }\n },\n json: (inputObjectTypeConfig: InputObjectTypeConfig, field: JSONField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n number: (inputObjectTypeConfig: InputObjectTypeConfig, field: NumberField) => {\n const type = field.name === 'id' ? GraphQLInt : GraphQLFloat\n return {\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(type) : type,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }\n },\n point: (inputObjectTypeConfig: InputObjectTypeConfig, field: PointField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({\n type: new GraphQLList(GraphQLFloat),\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n radio: (inputObjectTypeConfig: InputObjectTypeConfig, field: RadioField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n relationship: (inputObjectTypeConfig: InputObjectTypeConfig, field: RelationshipField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n richText: (inputObjectTypeConfig: InputObjectTypeConfig, field: RichTextField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLJSON, field, forceNullable, parentIsLocalized }),\n },\n }),\n row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>\n field.fields.reduce((acc, subField: Field) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(acc, subField)\n }\n return acc\n }, inputObjectTypeConfig),\n select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {\n const formattedName = `${combineParentName(parentName, field.name)}_MutationInput`\n let type: GraphQLType = new GraphQLEnumType({\n name: formattedName,\n values: field.options.reduce((values, option) => {\n if (optionIsObject(option)) {\n return {\n ...values,\n [formatName(option.value)]: {\n value: option.value,\n },\n }\n }\n\n return {\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }\n }, {}),\n })\n\n type = field.hasMany ? new GraphQLList(type) : type\n type = withNullableType({ type, field, forceNullable, parentIsLocalized })\n\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type },\n }\n },\n tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => {\n return field.tabs.reduce((acc, tab) => {\n if (tabHasName(tab)) {\n const fullName = combineParentName(parentName, toWords(tab.name, true))\n const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)\n let type: GraphQLType = buildMutationInputType({\n name: fullName,\n config,\n fields: tab.fields,\n graphqlResult,\n parentIsLocalized: parentIsLocalized || tab.localized,\n parentName: fullName,\n })\n\n if (!type) {\n return acc\n }\n\n if (requiresAtLeastOneField) {\n type = new GraphQLNonNull(type)\n }\n return {\n ...acc,\n [tab.name]: { type },\n }\n }\n\n return {\n ...acc,\n ...tab.fields.reduce((subFieldSchema, subField) => {\n const addSubField = fieldToSchemaMap[subField.type]\n if (addSubField) {\n return addSubField(subFieldSchema, subField)\n }\n return subFieldSchema\n }, acc),\n }\n }, inputObjectTypeConfig)\n },\n text: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({\n type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,\n field,\n forceNullable,\n parentIsLocalized,\n }),\n },\n }),\n textarea: (inputObjectTypeConfig: InputObjectTypeConfig, field: TextareaField) => ({\n ...inputObjectTypeConfig,\n [field.name]: {\n type: withNullableType({ type: GraphQLString, field, forceNullable, parentIsLocalized }),\n },\n }),\n upload: (inputObjectTypeConfig: InputObjectTypeConfig, field: UploadField) => {\n const { relationTo } = field\n type PayloadGraphQLRelationshipType =\n | GraphQLInputObjectType\n | GraphQLList<GraphQLScalarType>\n | GraphQLScalarType\n let type: PayloadGraphQLRelationshipType\n\n if (Array.isArray(relationTo)) {\n const fullName = `${combineParentName(\n parentName,\n toWords(field.name, true),\n )}RelationshipInput`\n type = new GraphQLInputObjectType({\n name: fullName,\n fields: {\n relationTo: {\n type: new GraphQLEnumType({\n name: `${fullName}RelationTo`,\n values: relationTo.reduce(\n (values, option) => ({\n ...values,\n [formatName(option)]: {\n value: option,\n },\n }),\n {},\n ),\n }),\n },\n value: { type: GraphQLJSON },\n },\n })\n } else {\n type = getCollectionIDType(\n config.db.defaultIDType,\n graphqlResult.collections[relationTo].config,\n )\n }\n\n return {\n ...inputObjectTypeConfig,\n [field.name]: { type: field.hasMany ? new GraphQLList(type) : type },\n }\n },\n }\n\n const fieldName = formatName(name)\n\n const fieldSchemas = fields.reduce((inputObjectTypeConfig, field) => {\n const fieldSchema = fieldToSchemaMap[field.type]\n\n if (typeof fieldSchema !== 'function') {\n return inputObjectTypeConfig\n }\n\n const schema = fieldSchema(inputObjectTypeConfig, field)\n if (Object.keys(schema).length === 0) {\n return inputObjectTypeConfig\n }\n\n return {\n ...inputObjectTypeConfig,\n ...fieldSchema(inputObjectTypeConfig, field),\n }\n }, {})\n\n if (Object.keys(fieldSchemas).length === 0) {\n return null\n }\n\n return new GraphQLInputObjectType({\n name: `mutation${fieldName}Input`,\n fields: fieldSchemas,\n })\n}\n"],"names":["GraphQLBoolean","GraphQLEnumType","GraphQLFloat","GraphQLInputObjectType","GraphQLInt","GraphQLList","GraphQLNonNull","GraphQLString","flattenTopLevelFields","toWords","fieldAffectsData","optionIsObject","tabHasName","GraphQLJSON","combineParentName","formatName","groupOrTabHasRequiredSubfield","withNullableType","idFieldTypes","number","text","getCollectionIDType","type","collection","idField","fields","find","field","name","buildMutationInputType","config","forceNullable","graphqlResult","parentIsLocalized","parentName","fieldToSchemaMap","array","inputObjectTypeConfig","fullName","localized","blocks","checkbox","code","collapsible","reduce","acc","subField","addSubField","date","email","group","requiresAtLeastOneField","json","hasMany","point","radio","relationship","relationTo","Array","isArray","values","option","value","db","defaultIDType","collections","richText","row","select","formattedName","options","tabs","tab","subFieldSchema","textarea","upload","fieldName","fieldSchemas","fieldSchema","schema","Object","keys","length"],"mappings":"AA4BA,SACEA,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,sBAAsB,EACtBC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,QACR,UAAS;AAChB,SAASC,qBAAqB,EAAEC,OAAO,QAAQ,UAAS;AACxD,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,UAAU,QAAQ,iBAAgB;AAE7E,SAASC,WAAW,QAAQ,yCAAwC;AACpE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SA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Y;oBAC7B;gBACF;YACF,OAAO;gBACLS,OAAOD,oBACLS,OAAOiC,EAAE,CAACC,aAAa,EACvBhC,cAAciC,WAAW,CAACR,WAAW,CAAC3B,MAAM;YAEhD;YAEA,OAAO;gBACL,GAAGO,qBAAqB;gBACxB,CAACV,MAAMC,IAAI,CAAC,EAAE;oBAAEN,MAAMK,MAAM0B,OAAO,GAAG,IAAIhD,YAAYiB,QAAQA;gBAAK;YACrE;QACF;IACF;IAEA,MAAMsD,YAAY7D,WAAWa;IAE7B,MAAMiD,eAAepD,OAAOmB,MAAM,CAAC,CAACP,uBAAuBV;QACzD,MAAMmD,cAAc3C,gBAAgB,CAACR,MAAML,IAAI,CAAC;QAEhD,IAAI,OAAOwD,gBAAgB,YAAY;YACrC,OAAOzC;QACT;QAEA,MAAM0C,SAASD,YAAYzC,uBAAuBV;QAClD,IAAIqD,OAAOC,IAAI,CAACF,QAAQG,MAAM,KAAK,GAAG;YACpC,OAAO7C;QACT;QAEA,OAAO;YACL,GAAGA,qBAAqB;YACxB,GAAGyC,YAAYzC,uBAAuBV,MAAM;QAC9C;IACF,GAAG,CAAC;IAEJ,IAAIqD,OAAOC,IAAI,CAACJ,cAAcK,MAAM,KAAK,GAAG;QAC1C,OAAO;IACT;IAEA,OAAO,IAAI/E,uBAAuB;QAChCyB,MAAM,CAAC,QAAQ,EAAEgD,UAAU,KAAK,CAAC;QACjCnD,QAAQoD;IACV;AACF"}
@@ -11,8 +11,9 @@ type Args = {
11
11
  forceNullable?: boolean;
12
12
  graphqlResult: GraphQLInfo;
13
13
  name: string;
14
+ parentIsLocalized?: boolean;
14
15
  parentName: string;
15
16
  };
16
- export declare function buildObjectType({ name, baseFields, config, fields, forceNullable, graphqlResult, parentName, }: Args): GraphQLObjectType;
17
+ export declare function buildObjectType({ name, baseFields, config, fields, forceNullable, graphqlResult, parentIsLocalized, parentName, }: Args): GraphQLObjectType;
17
18
  export {};
18
19
  //# sourceMappingURL=buildObjectType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildObjectType.d.ts","sourceRoot":"","sources":["../../src/schema/buildObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EAWX,eAAe,EAMhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAOL,iBAAiB,EAGlB,MAAM,SAAS,CAAA;AAchB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CAC7C,CAAA;AAED,KAAK,IAAI,GAAG;IACV,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,UAAe,EACf,MAAM,EACN,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,GACX,EAAE,IAAI,GAAG,iBAAiB,CA00B1B"}
1
+ {"version":3,"file":"buildObjectType.d.ts","sourceRoot":"","sources":["../../src/schema/buildObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAQV,KAAK,EACL,WAAW,EAWX,eAAe,EAMhB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAOL,iBAAiB,EAGlB,MAAM,SAAS,CAAA;AAchB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CAC7C,CAAA;AAED,KAAK,IAAI,GAAG;IACV,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,WAAW,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,UAAe,EACf,MAAM,EACN,MAAM,EACN,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,EAAE,IAAI,GAAG,iBAAiB,CA02B1B"}
@@ -8,7 +8,7 @@ import { formatName } from '../utilities/formatName.js';
8
8
  import { formatOptions } from '../utilities/formatOptions.js';
9
9
  import { isFieldNullable } from './isFieldNullable.js';
10
10
  import { withNullableType } from './withNullableType.js';
11
- export function buildObjectType({ name, baseFields = {}, config, fields, forceNullable, graphqlResult, parentName }) {
11
+ export function buildObjectType({ name, baseFields = {}, config, fields, forceNullable, graphqlResult, parentIsLocalized, parentName }) {
12
12
  const fieldToSchemaMap = {
13
13
  array: (objectTypeConfig, field)=>{
14
14
  const interfaceName = field?.interfaceName || combineParentName(parentName, toWords(field.name, true));
@@ -17,8 +17,13 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
17
17
  name: interfaceName,
18
18
  config,
19
19
  fields: field.fields,
20
- forceNullable: isFieldNullable(field, forceNullable),
20
+ forceNullable: isFieldNullable({
21
+ field,
22
+ forceNullable,
23
+ parentIsLocalized
24
+ }),
21
25
  graphqlResult,
26
+ parentIsLocalized: field.localized || parentIsLocalized,
22
27
  parentName: interfaceName
23
28
  });
24
29
  if (Object.keys(objectType.getFields()).length) {
@@ -32,7 +37,11 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
32
37
  return {
33
38
  ...objectTypeConfig,
34
39
  [field.name]: {
35
- type: withNullableType(field, arrayType)
40
+ type: withNullableType({
41
+ type: arrayType,
42
+ field,
43
+ parentIsLocalized
44
+ })
36
45
  }
37
46
  };
38
47
  },
@@ -55,6 +64,7 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
55
64
  ],
56
65
  forceNullable,
57
66
  graphqlResult,
67
+ parentIsLocalized,
58
68
  parentName: interfaceName
59
69
  });
60
70
  if (Object.keys(objectType.getFields()).length) {
@@ -78,20 +88,34 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
78
88
  return {
79
89
  ...objectTypeConfig,
80
90
  [field.name]: {
81
- type: withNullableType(field, type)
91
+ type: withNullableType({
92
+ type,
93
+ field,
94
+ parentIsLocalized
95
+ })
82
96
  }
83
97
  };
84
98
  },
85
99
  checkbox: (objectTypeConfig, field)=>({
86
100
  ...objectTypeConfig,
87
101
  [field.name]: {
88
- type: withNullableType(field, GraphQLBoolean, forceNullable)
102
+ type: withNullableType({
103
+ type: GraphQLBoolean,
104
+ field,
105
+ forceNullable,
106
+ parentIsLocalized
107
+ })
89
108
  }
90
109
  }),
91
110
  code: (objectTypeConfig, field)=>({
92
111
  ...objectTypeConfig,
93
112
  [field.name]: {
94
- type: withNullableType(field, GraphQLString, forceNullable)
113
+ type: withNullableType({
114
+ type: GraphQLString,
115
+ field,
116
+ forceNullable,
117
+ parentIsLocalized
118
+ })
95
119
  }
96
120
  }),
97
121
  collapsible: (objectTypeConfig, field)=>field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField)=>{
@@ -104,13 +128,23 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
104
128
  date: (objectTypeConfig, field)=>({
105
129
  ...objectTypeConfig,
106
130
  [field.name]: {
107
- type: withNullableType(field, DateTimeResolver, forceNullable)
131
+ type: withNullableType({
132
+ type: DateTimeResolver,
133
+ field,
134
+ forceNullable,
135
+ parentIsLocalized
136
+ })
108
137
  }
109
138
  }),
110
139
  email: (objectTypeConfig, field)=>({
111
140
  ...objectTypeConfig,
112
141
  [field.name]: {
113
- type: withNullableType(field, EmailAddressResolver, forceNullable)
142
+ type: withNullableType({
143
+ type: EmailAddressResolver,
144
+ field,
145
+ forceNullable,
146
+ parentIsLocalized
147
+ })
114
148
  }
115
149
  }),
116
150
  group: (objectTypeConfig, field)=>{
@@ -120,8 +154,13 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
120
154
  name: interfaceName,
121
155
  config,
122
156
  fields: field.fields,
123
- forceNullable: isFieldNullable(field, forceNullable),
157
+ forceNullable: isFieldNullable({
158
+ field,
159
+ forceNullable,
160
+ parentIsLocalized
161
+ }),
124
162
  graphqlResult,
163
+ parentIsLocalized: field.localized || parentIsLocalized,
125
164
  parentName: interfaceName
126
165
  });
127
166
  if (Object.keys(objectType.getFields()).length) {
@@ -162,6 +201,9 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
162
201
  limit: {
163
202
  type: GraphQLInt
164
203
  },
204
+ page: {
205
+ type: GraphQLInt
206
+ },
165
207
  sort: {
166
208
  type: GraphQLString
167
209
  },
@@ -174,7 +216,7 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
174
216
  },
175
217
  async resolve (parent, args, context) {
176
218
  const { collection } = field;
177
- const { limit, sort, where } = args;
219
+ const { limit, page, sort, where } = args;
178
220
  const { req } = context;
179
221
  const fullWhere = combineQueries(where, {
180
222
  [field.on]: {
@@ -188,6 +230,7 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
188
230
  limit,
189
231
  locale: req.locale,
190
232
  overrideAccess: false,
233
+ page,
191
234
  req,
192
235
  sort,
193
236
  where: fullWhere
@@ -202,7 +245,12 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
202
245
  json: (objectTypeConfig, field)=>({
203
246
  ...objectTypeConfig,
204
247
  [field.name]: {
205
- type: withNullableType(field, GraphQLJSON, forceNullable)
248
+ type: withNullableType({
249
+ type: GraphQLJSON,
250
+ field,
251
+ forceNullable,
252
+ parentIsLocalized
253
+ })
206
254
  }
207
255
  }),
208
256
  number: (objectTypeConfig, field)=>{
@@ -210,23 +258,38 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
210
258
  return {
211
259
  ...objectTypeConfig,
212
260
  [field.name]: {
213
- type: withNullableType(field, field?.hasMany === true ? new GraphQLList(type) : type, forceNullable)
261
+ type: withNullableType({
262
+ type: field?.hasMany === true ? new GraphQLList(type) : type,
263
+ field,
264
+ forceNullable,
265
+ parentIsLocalized
266
+ })
214
267
  }
215
268
  };
216
269
  },
217
270
  point: (objectTypeConfig, field)=>({
218
271
  ...objectTypeConfig,
219
272
  [field.name]: {
220
- type: withNullableType(field, new GraphQLList(new GraphQLNonNull(GraphQLFloat)), forceNullable)
273
+ type: withNullableType({
274
+ type: new GraphQLList(new GraphQLNonNull(GraphQLFloat)),
275
+ field,
276
+ forceNullable,
277
+ parentIsLocalized
278
+ })
221
279
  }
222
280
  }),
223
281
  radio: (objectTypeConfig, field)=>({
224
282
  ...objectTypeConfig,
225
283
  [field.name]: {
226
- type: withNullableType(field, new GraphQLEnumType({
227
- name: combineParentName(parentName, field.name),
228
- values: formatOptions(field)
229
- }), forceNullable)
284
+ type: withNullableType({
285
+ type: new GraphQLEnumType({
286
+ name: combineParentName(parentName, field.name),
287
+ values: formatOptions(field)
288
+ }),
289
+ field,
290
+ forceNullable,
291
+ parentIsLocalized
292
+ })
230
293
  }
231
294
  }),
232
295
  relationship: (objectTypeConfig, field)=>{
@@ -293,7 +356,12 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
293
356
  };
294
357
  }
295
358
  const relationship = {
296
- type: withNullableType(field, hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type, forceNullable),
359
+ type: withNullableType({
360
+ type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,
361
+ field,
362
+ forceNullable,
363
+ parentIsLocalized
364
+ }),
297
365
  args: relationshipArgs,
298
366
  extensions: {
299
367
  complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10
@@ -396,7 +464,12 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
396
464
  richText: (objectTypeConfig, field)=>({
397
465
  ...objectTypeConfig,
398
466
  [field.name]: {
399
- type: withNullableType(field, GraphQLJSON, forceNullable),
467
+ type: withNullableType({
468
+ type: GraphQLJSON,
469
+ field,
470
+ forceNullable,
471
+ parentIsLocalized
472
+ }),
400
473
  args: {
401
474
  depth: {
402
475
  type: GraphQLInt
@@ -433,6 +506,7 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
433
506
  findMany: false,
434
507
  flattenLocales: false,
435
508
  overrideAccess: false,
509
+ parentIsLocalized,
436
510
  populationPromises,
437
511
  req: context.req,
438
512
  showHiddenFields: false,
@@ -459,7 +533,12 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
459
533
  values: formatOptions(field)
460
534
  });
461
535
  type = field.hasMany ? new GraphQLList(new GraphQLNonNull(type)) : type;
462
- type = withNullableType(field, type, forceNullable);
536
+ type = withNullableType({
537
+ type,
538
+ field,
539
+ forceNullable,
540
+ parentIsLocalized
541
+ });
463
542
  return {
464
543
  ...objectTypeConfig,
465
544
  [field.name]: {
@@ -477,6 +556,7 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
477
556
  fields: tab.fields,
478
557
  forceNullable,
479
558
  graphqlResult,
559
+ parentIsLocalized: tab.localized || parentIsLocalized,
480
560
  parentName: interfaceName
481
561
  });
482
562
  if (Object.keys(objectType.getFields()).length) {
@@ -513,13 +593,23 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
513
593
  text: (objectTypeConfig, field)=>({
514
594
  ...objectTypeConfig,
515
595
  [field.name]: {
516
- type: withNullableType(field, field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString, forceNullable)
596
+ type: withNullableType({
597
+ type: field.hasMany === true ? new GraphQLList(GraphQLString) : GraphQLString,
598
+ field,
599
+ forceNullable,
600
+ parentIsLocalized
601
+ })
517
602
  }
518
603
  }),
519
604
  textarea: (objectTypeConfig, field)=>({
520
605
  ...objectTypeConfig,
521
606
  [field.name]: {
522
- type: withNullableType(field, GraphQLString, forceNullable)
607
+ type: withNullableType({
608
+ type: GraphQLString,
609
+ field,
610
+ forceNullable,
611
+ parentIsLocalized
612
+ })
523
613
  }
524
614
  }),
525
615
  upload: (objectTypeConfig, field)=>{
@@ -584,7 +674,12 @@ export function buildObjectType({ name, baseFields = {}, config, fields, forceNu
584
674
  };
585
675
  }
586
676
  const relationship = {
587
- type: withNullableType(field, hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type, forceNullable),
677
+ type: withNullableType({
678
+ type: hasManyValues ? new GraphQLList(new GraphQLNonNull(type)) : type,
679
+ field,
680
+ forceNullable,
681
+ parentIsLocalized
682
+ }),
588
683
  args: relationshipArgs,
589
684
  extensions: {
590
685
  complexity: typeof field?.graphQL?.complexity === 'number' ? field.graphQL.complexity : 10