GavinXue / strapi-study-cases

strapi use cases when study, maybe it can help someone else.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

strapi-study-cases

This Repo show some cases of using Strapi - Open source Node.js Headless CMS 🚀, I do always confused by offcial docs, as a newer to strapi I record some running example to study.

Flatten Graphql Result of V4

If you want flatten graphql result of v4, visit graphql modified docs

Run the cases

Run these cases local:

git clone https://github.com/GavinXue/strapi-study-cases.git
yarn     # or npm install
yarn develop    # or npm run develop

Run thest cases online: warn: It seems this does not work on stackblitz, beause of some unsupported shell syntax(JSH). check some problem Strapi on Stackblitz

I have tried that it is worked on replit. and the file .replit and replit.nix are the config file for replit.(import github repo to replit, then click run, and wait) replit repo work link

Due to I have update the sqllite db to github. When run these cases the test strapi, you can directly login with:

name: strapi@test.com
password:: Strapi2022

apiToken: the description of test token is the actual token (use it directly.) or you can creat a new one.

Introduce Some Case

add a refresh token api

reference: strapi docs
when token expired, you can issue a new token. and when you want customize other plugin's interface, it should be the same logic.
case code: /src/extensions/users-permissions/strapi-server.js

add customizing graphql query as refreshToken

reference: strapi docs
should be modify the entry file: ./src/index.js
if customizing more types or apis, taking these code to a new module may be better.
case code: ./src/extensions/graphql

extend core controllers

reference: Backend customization - Controllers - Strapi Developer Docs

This comes from a question in Auto populate title field with content from other fields - Questions and Answers - Strapi Community Forum .

solve it to extend entity update and create controller. case code: ./src/api/house/controllers/house.js

set limitation of populate fields

This comes from How to set Limit of a relation - Discussions - Strapi Community Forum It still a extend core controller problem.

case code: ./src/api/article/controllers/article.js

Some Questions

About

strapi use cases when study, maybe it can help someone else.


Languages

Language:TypeScript 67.8%Language:JavaScript 32.1%Language:Shell 0.0%Language:Nix 0.0%