enables properly building object type for Row field type

This commit is contained in:
James
2020-06-02 20:31:05 -04:00
parent 66f55a593f
commit b4e2e2e1b6
2 changed files with 39 additions and 18 deletions

View File

@@ -243,6 +243,20 @@ function buildObjectType(name, fields, parentName, baseFields = {}) {
return { type };
},
row: (field) => {
return field.fields.reduce((subFieldSchema, subField) => {
const buildSchemaType = fieldToSchemaMap[subField.type];
if (buildSchemaType) {
return {
...subFieldSchema,
[formatName(subField.name)]: buildSchemaType(subField),
};
}
return subFieldSchema;
}, {});
},
};
const objectSchema = {
@@ -250,9 +264,16 @@ function buildObjectType(name, fields, parentName, baseFields = {}) {
fields: () => fields.reduce((schema, field) => {
const fieldSchema = fieldToSchemaMap[field.type];
if (fieldSchema) {
if (field.name) {
return {
...schema,
[formatName(field.name)]: fieldSchema(field),
};
}
return {
...schema,
[formatName(field.name)]: fieldSchema(field),
...fieldSchema(field),
};
}