Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
31 lines
1.2 KiB
Plaintext
31 lines
1.2 KiB
Plaintext
import { GraphQLObjectType } from 'graphql';
|
|
import { fieldToSchemaMap } from './fieldToSchemaMap.js';
|
|
export function buildObjectType({ name, baseFields = {}, collectionSlug, config, fields, forceNullable, graphqlResult, parentIsLocalized, parentName }) {
|
|
const objectSchema = {
|
|
name,
|
|
fields: ()=>fields.reduce((objectTypeConfig, field)=>{
|
|
const fieldSchema = fieldToSchemaMap[field.type];
|
|
if (typeof fieldSchema !== 'function') {
|
|
return objectTypeConfig;
|
|
}
|
|
return {
|
|
...objectTypeConfig,
|
|
...fieldSchema({
|
|
collectionSlug,
|
|
config,
|
|
field,
|
|
forceNullable,
|
|
graphqlResult,
|
|
newlyCreatedBlockType,
|
|
objectTypeConfig,
|
|
parentIsLocalized,
|
|
parentName
|
|
})
|
|
};
|
|
}, baseFields)
|
|
};
|
|
const newlyCreatedBlockType = new GraphQLObjectType(objectSchema);
|
|
return newlyCreatedBlockType;
|
|
}
|
|
|
|
//# sourceMappingURL=buildObjectType.js.map |