First working version of graphql rework w/ the new plugin API

This commit is contained in:
Convly 2021-08-23 19:47:27 +02:00
parent 21045d8936
commit 2ea04f1cd4
3 changed files with 8 additions and 6 deletions

View File

@ -32,7 +32,10 @@ module.exports = async strapi => {
// Initialize loaders for this request.
context: ({ ctx }) => {
// TODO: set loaders in the context not globally
strapi.plugins.graphql.services.old['data-loaders'].initializeLoader();
strapi
.plugin('graphql')
.service('old')
['data-loaders'].initializeLoader();
return {
context: ctx,
@ -80,8 +83,6 @@ module.exports = async strapi => {
path: config.endpoint,
});
console.log(config.endpoint);
// Register destroy behavior
strapi.plugins.graphql.destroy = async () => {
await server.stop();

View File

@ -211,7 +211,7 @@ const addMediaAttribute = options => {
context: { strapi },
} = options;
const fileContentType = strapi.plugin('upload').contentType('file');
const fileContentType = strapi.plugin('upload').contentType('file').schema;
const resolve = buildAssociationResolver({
contentTypeUID: contentType.uid,

View File

@ -90,9 +90,9 @@ const getEnumName = (contentType, attributeName) => {
const getTypeName = contentType => {
const plugin = get('plugin', contentType);
const modelName = get('modelName', contentType);
const singularName = get('schema.info.singularName', contentType);
const singularName = get('info.singularName', contentType);
const transformedPlugin = camelCase(plugin);
const transformedPlugin = upperFirst(camelCase(plugin));
const transformedModelName = upperFirst(singularName || toSingular(modelName));
return `${transformedPlugin}${transformedModelName}`;
@ -243,6 +243,7 @@ const getMorphRelationTypeName = (contentType, attributeName) => {
* @return {function(*=): string}
*/
const buildCustomTypeNameGenerator = (options = {}) => {
// todo[v4]: use singularName & pluralName is available
const { prefix = '', suffix = '', plurality = 'singular', firstLetterCase = 'upper' } = options;
if (!['plural', 'singular'].includes(plurality)) {