-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solveIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: plugin:graphqlSource is plugin/graphql packageSource is plugin/graphql packagestatus: pending reproductionWaiting for free time to reproduce the issue, or more informationWaiting for free time to reproduce the issue, or more information
Description
Bug report
Describe the bug
I develop a blog with posts in Russian language.
It's nice to have correct looking quote marks, so I am using npm package Typograf to override quote marks in posts's controller.
Overriding controller works in REST API, but doesn't work in GraphQL.
It worked nice in Strapi v3, and recently in Strapi v4, but it doesn't work now.
Steps to reproduce the behavior
- Go to src/api/post/controllers/posts.js
- Add code to change quote marks (the code is below)
- Go to GraphQL and request the one post or posts
- See error: the quote marks are not changed.
- Go to REST API and request the one post or posts
- There is no error: quote marks are replaced.
Expected behavior
The quote marks should be replaced from " to « and ».
It's the way to understand that Typograf works.
Screenshots
GraphQL: the error
REST API: no error
The NextJS app with the request from GraphQL: the error
Code snippets
My code of the post's controller:
'use strict';
// const { sanitizeEntity } = require('strapi-utils');
const Typograf = require('typograf');
/**
* post controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
const tp = new Typograf({locale: ['ru', 'en-US']});
// module.exports = createCoreController('api::post.post');
module.exports = createCoreController('api::post.post', ({ strapi }) => ({
async find(ctx) {
// some custom logic here
// Calling the default core action
const { data, meta } = await super.find(ctx);
// I don't know how to do the same as in findOne part, but it should be here
return { data, meta };
},
// Method 3: Replacing a core action
async findOne(ctx) {
const { id } = ctx.params;
const { query } = ctx;
const entity = await strapi.service('api::post.post').findOne(id, query);
// console.log(entity);
if (entity) {
if (entity.title) {entity.title = tp.execute(entity.title);}
if (entity.subtitle) {entity.subtitle = tp.execute(entity.subtitle);}
if (entity.description) {entity.description = tp.execute(entity.description);}
if (entity.content) {entity.content = tp.execute(entity.content);}
}
const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
return this.transformResponse(sanitizedEntity);
}
}));
System
- Node.js version: 14.17.5
- NPM version: 6.14.14
- Strapi version: 4.0.5
- Database: SQLite
- Operating system: MacOS
Additional context
Overriding controller worked at 4.0.2 and probably 4.0.3, but it doesn't work at 4.0.4 and 4.0.5.
Metadata
Metadata
Assignees
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solveIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: plugin:graphqlSource is plugin/graphql packageSource is plugin/graphql packagestatus: pending reproductionWaiting for free time to reproduce the issue, or more informationWaiting for free time to reproduce the issue, or more information


