{"id":18750638,"url":"https://github.com/webiny/webiny-js-data-mock","last_synced_at":"2025-11-26T20:30:17.639Z","repository":{"id":242713032,"uuid":"668271178","full_name":"webiny/webiny-js-data-mock","owner":"webiny","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-10T08:17:56.000Z","size":2517,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-10T09:29:50.157Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webiny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-19T12:18:38.000Z","updated_at":"2025-01-10T08:17:59.000Z","dependencies_parsed_at":"2024-06-04T16:21:56.553Z","dependency_job_id":"dd903ac5-1a50-4a87-918b-282227b44df2","html_url":"https://github.com/webiny/webiny-js-data-mock","commit_stats":null,"previous_names":["webiny/webiny-js-data-mock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2Fwebiny-js-data-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2Fwebiny-js-data-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2Fwebiny-js-data-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webiny%2Fwebiny-js-data-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webiny","download_url":"https://codeload.github.com/webiny/webiny-js-data-mock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239635836,"owners_count":19672239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T17:12:40.105Z","updated_at":"2025-11-26T20:30:17.563Z","avatar_url":"https://github.com/webiny.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Webiny Data Mock\n\nAdd .env file into the project root and fill it with:\n````\nAPI_GRAPHQL_URL=https://xxxxxxx.cloudfront.net\nAPI_TOKEN=xxxxxxx\n````\n\n\nRun with\n`````\nyarn create-data\n`````\n\n## Blog mock data (id: blog)\n\nThe blog mock data creates:\n\n- categories\n- authors\n- articles\n\n### Categories\n\nCategory list is hardcoded, there is 10 of them.\n\n### Authors\n\nAuthors list is hardcoded, there is 7 of them.\n\n### Articles\n\nArticle structure is hardcoded, but the content is modified with the author name and category titles - as there can be\nmultiple categories attached to an article.\n\nThere are modifier arguments for the create-data command:\n\n````\nyarn create-data --articles:amount=100 --articles:atOnce=10 --articles:startId=555\n````\n\nThe `articles:amount` defines how much articles will be generated - default is **100**.\n\nThe `articles:atOnce` defines how much articles will be created at once (how many mutations will be sent at once) -\ndefault is **10**.\n\nThe `articles:startId` defines the starting ID number of the articles - default is **1**.\n\n#### Skip creating blog articles\n\nIf you want to skip creating blog articles, add `--skip=cms:blog` argument to the create-data command:\n\n````\nyarn create-data --skip=cms:blog\n````\n\nNote that this will NOT skip group and models creation.\n\n## Car mock data (id: simpleCars)\n\n### Car Makes\n\nCar makes list is hardcoded, there is 39 of them.\n\n### Car Models\n\nCar models list is hardcoded, there is 892 of them.\n\nThere are modifier arguments for the create-data command:\n\n````\nyarn create-data --simpleCarModels:atOnce=10\n````\n\nThe `simpleCarModels:atOnce` defines how much car models will be created at once (how many mutations will be sent at once) -\ndefault is **10**.\n\n#### Skip creating simple cars\n\nIf you want to skip creating cars, add `--skip=cms:simpleCars` argument to the create-data command:\n\n````\nyarn create-data --skip=cms:simpleCars\n````\n\n\n## Fetch All Entries From A Certain Model\n\nYou can also fetch a list of entries from a certain model. For example, to fetch a list of articles, run:\n```\nyarn fetch-data --model=article --per-request=2000 --filename=articles.json\n```\nWhere:\n* `model` - is the modelId you want to fetch entries from\n* `per-request` - is the number of entries you want to fetch per request - default is **1000**\n* `max-requests` - is the maximum number of requests you want to allow to execute - default is **100**\n* `filename` - is the name of the file where the fetched entries will be saved - if no filename is given, you will only get info about the amount of entries fetched\n\nNote that, if you pass the `filename`, the fetched entries will contain only the allowed types of fields, defined [here](https://github.com/webiny/webiny-js-data-mock/blob/main/src/apps/utils/createModelFields.ts#L3).\n\n## Create Tenants\n\nYou can create tenants by running:\n\n```\nyarn create-tenants --tenants=aChildTenant,anotherChildTenant,....\n```\n\nBut for that to work, you need a code from `./code/tenants/` diretory in your project.\n\nJust copy the files and import the plugins via the `createTenantsMockDataPlugins()` from the `index.ts` file.\n\n## Create Completely Random Mock Data For Any Model\n\n### Add a custom authorizer which allows the `create-data-per-tenant` script to run\n\nTo be able to run the `create-data-per-tenant` script, you need to add a custom authorizer to your project. You can do\nthat by using the code in `./code/authorization` directory.\n\nJust copy the files and import the plugins via the `createAuthenticator()` from the `index.ts` file.\n\n### Creating the data\n\nYou can create completely random mock data for any model by running:\n\n```\nyarn create-data-per-tenant --tenants=yourTenantName --amount=1 --models=aModelId,anotherModelId,....\n```\n\nIn the `tenants` argument, you can pass multiple tenants separated by a comma or a `*` to target all existing tenants.\n\nIn the `amount` argument, you must send the amount of the records you want to create. Default is `5`.\n\nIn the `models` argument, you must send the `modelId` of the model you want to create the records for. Same as for the\ntenants, you can send multiple `modelId` separated by a comma or a `*` to target all existing models.\n\n#### Dry Run\n\nIf you do not wish to insert data immediately, but you want to see what will get inserted, you can add the `--dry-run` flag.\nIt will generate JSON file in `./dryRuns/ ` directory.\n\n#### IMPORTANT!\n\nWhen sending a `*`, make sure it is sent with quotes, like this: `\"*\"`. Otherwise, the script will fail.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebiny%2Fwebiny-js-data-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebiny%2Fwebiny-js-data-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebiny%2Fwebiny-js-data-mock/lists"}