mirror of
https://github.com/strapi/strapi.git
synced 2025-09-04 14:23:03 +00:00
27 lines
568 B
JavaScript
27 lines
568 B
JavaScript
'use strict';
|
|
|
|
const { unionType } = require('nexus');
|
|
const { prop } = require('lodash/fp');
|
|
|
|
const {
|
|
constants: { GENERIC_MORPH_TYPENAME },
|
|
} = require('../../types');
|
|
|
|
module.exports = ({ registry }) => ({
|
|
buildGenericMorphDefinition() {
|
|
return unionType({
|
|
name: GENERIC_MORPH_TYPENAME,
|
|
|
|
resolveType: prop('__typename'),
|
|
|
|
definition(t) {
|
|
const members = registry
|
|
.where(({ config }) => ['types', 'components'].includes(config.kind))
|
|
.map(prop('name'));
|
|
|
|
t.members(...members);
|
|
},
|
|
});
|
|
},
|
|
});
|