Skip to content

Sync a Questionnaire

Forward sync fetches a published questionnaire from the Strapi API and generates a TypeScript file that the React app imports.

Terminal window
yarn sync:questionnaire [options]
Flag Long form Type Default Description
-q --questionnaireSlug string Sync only one questionnaire by its slug
-t --questionnaireType enum all Filter by type: signup, claim, adjustPolicy, cancelPolicy, all
-d --dir string src/syncedData/questionnaires Output directory for generated files
-s --source enum Source environment: prod, staging, dev. Falls back to REACT_APP_STRAPI_URL / REACT_APP_STRAPI_TOKEN env vars when omitted.

Sync a single questionnaire by slug and type:

Terminal window
yarn sync:questionnaire -q household -t signup

Sync all questionnaires from production:

Terminal window
yarn sync:questionnaire -s prod

Sync only claim questionnaires from staging:

Terminal window
yarn sync:questionnaire -t claim -s staging

Sync to a custom output directory:

Terminal window
yarn sync:questionnaire -q household -d src/custom/output
  1. The script calls the Strapi API to fetch the published version of the questionnaire
  2. Strapi’s service layer transforms the data into canonical format (flattened questions, simplified rules)
  3. The script wraps all translatable strings with t() function calls for i18n
  4. The output is linted automatically
  5. The generated file is written to:
apps/app/src/syncedData/questionnaires/<slug>.ts

Files are placed in subdirectories by type: claims/, adjustPolicy/, cancelPolicy/, or dependents/ for dependent variants. Signup questionnaires land at the root of the output directory.

  1. Open the generated file and review it
  2. Verify questions, rules, and screen text look correct
  3. Commit the file and open a PR
  4. The change goes through normal code review and deployment
Issue Cause Fix
“Failed to fetch questionnaire” Strapi URL or token misconfigured Check REACT_APP_STRAPI_URL and REACT_APP_STRAPI_TOKEN env vars, or pass --source to use named credentials
“No questionnaires found” (empty output) Slug typo or questionnaire not published Verify the slug spelling matches Strapi and ensure the questionnaire is published
“Permission denied” or 401/403 API token lacks read access Check that the Strapi API token has read permissions for the questionnaire content type
File not generated Output directory does not exist or wrong path Verify the target directory exists; use -d to specify a valid path
“Questionnaire not found” Slug does not match or not published Check the name field in Strapi, ensure it is published
  • Sync Commands Reference – full CLI reference with all flags and options
  • Syncing and Previewing – end-to-end tutorial for the sync workflow
  • Strapi Transform Pipeline – how data is reshaped during sync | Missing questions | Questions added but not saved | Save the questionnaire in Strapi | | Stale data | Cached API response | Re-run the sync command |