Strapi 4 hide some fields for public API requests

System Information
  • Strapi Version: 4
  • Operating System: Windows 11
  • Database: PostgreSQL
  • Node Version: 16.13.1
  • NPM Version: 8.3.0
  • Yarn Version: 3.1.1

Hi, I have a static website with Strapi as CMS. I created an Article content type with title, slug, image, content fields. then I generated a read-only API token for generating my website. I also have search functionality in my website, and the user must be able to search through articles but the API response must return title, slug and image fields. and hide the content field. it’s a simple field-level permission for public role. I want to do it on both REST and GraphQL. what is the best practice for that?

in strapi 3 i created a “articles/search” route with a custom resolver that returns just the title, slug and image fields. and in the admin panel select “search” action for public role. but I didn’t have any solutions for graphQL(I know i can create custom resolvers but it takes a long time).

How can i implement it in strapi 4 for both REST and GrapgQL?