mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 02:44:13 +00:00
28 lines
665 B
JavaScript
28 lines
665 B
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
const { objectType } = require('nexus');
|
||
|
|
||
|
const { utils } = require('../../types');
|
||
|
|
||
|
/**
|
||
|
* Build a type definition for a content API response for a given content type
|
||
|
* @param {object} contentType The content type which will be used to build its content API response definition
|
||
|
* @return {NexusObjectTypeDef}
|
||
|
*/
|
||
|
const buildResponseDefinition = contentType => {
|
||
|
const name = utils.getEntityResponseName(contentType);
|
||
|
const entityName = utils.getEntityName(contentType);
|
||
|
|
||
|
return objectType({
|
||
|
name,
|
||
|
|
||
|
definition(t) {
|
||
|
t.field('data', { type: entityName });
|
||
|
},
|
||
|
});
|
||
|
};
|
||
|
|
||
|
module.exports = () => ({
|
||
|
buildResponseDefinition,
|
||
|
});
|