strapi/packages/plugins/graphql/server/services/utils/mappers/strapi-scalar-to-graphql-scalar.js
Jean-Sébastien Herbaux 8d9ea0f13e
[V4] GraphQL - Single types mutations implementation (#10923)
* Use new path for Strapi app attribute

* Add 'uid' to the list of existing Strapi scalars

* Fix single types queries definitions

* Remove ID from single types args

* Remove useless comments

* Fix typos

* Fix localizations populate in i18n core-api createLocalization handler

* Single type custom mutations implementation
2021-09-09 11:31:29 +02:00

25 lines
718 B
JavaScript

'use strict';
const { get, difference } = require('lodash/fp');
module.exports = ({ strapi }) => {
const { STRAPI_SCALARS, SCALARS_ASSOCIATIONS } = strapi.plugin('graphql').service('constants');
const missingStrapiScalars = difference(STRAPI_SCALARS, Object.keys(SCALARS_ASSOCIATIONS));
if (missingStrapiScalars.length > 0) {
throw new Error('Some Strapi scalars are not handled in the GraphQL scalars mapper');
}
return {
/**
* Used to transform a Strapi scalar type into its GraphQL equivalent
* @param {string} strapiScalar
* @return {NexusGenScalars}
*/
strapiScalarToGraphQLScalar(strapiScalar) {
return get(strapiScalar, SCALARS_ASSOCIATIONS);
},
};
};