{"id":22491805,"url":"https://github.com/always-open/laravel-graphql-schema-generator","last_synced_at":"2025-08-03T00:31:10.147Z","repository":{"id":56869305,"uuid":"520956431","full_name":"always-open/laravel-graphql-schema-generator","owner":"always-open","description":"Generate a GraphQL schema from your existing Laravel models and database","archived":false,"fork":false,"pushed_at":"2023-07-18T17:07:49.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"1.x","last_synced_at":"2024-11-24T19:20:39.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/always-open.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null}},"created_at":"2022-08-03T16:32:57.000Z","updated_at":"2024-10-03T19:30:10.000Z","dependencies_parsed_at":"2023-01-21T14:15:08.472Z","dependency_job_id":null,"html_url":"https://github.com/always-open/laravel-graphql-schema-generator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/always-open%2Flaravel-graphql-schema-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/always-open%2Flaravel-graphql-schema-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/always-open%2Flaravel-graphql-schema-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/always-open%2Flaravel-graphql-schema-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/always-open","download_url":"https://codeload.github.com/always-open/laravel-graphql-schema-generator/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228508031,"owners_count":17931263,"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-12-06T18:11:16.152Z","updated_at":"2024-12-06T18:11:16.969Z","avatar_url":"https://github.com/always-open.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/support-ukraine.svg?t=1\" /\u003e](https://supportukrainenow.org)\n\n# Generate GraphQL schema from existing Laravel models/database\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/always-open/laravel-graphql-schema-generator.svg?style=flat-square)](https://packagist.org/packages/always-open/laravel-graphql-schema-generator)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/always-open/laravel-graphql-schema-generator/run-tests?label=tests)](https://github.com/always-open/laravel-graphql-schema-generator/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/always-open/laravel-graphql-schema-generator/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/always-open/laravel-graphql-schema-generator/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/always-open/laravel-graphql-schema-generator.svg?style=flat-square)](https://packagist.org/packages/always-open/laravel-graphql-schema-generator)\n\nThis package will generate a GraphQL schema from your existing Laravel models and database. It reads through the \nexisting models, relationships, and database to generate a GraphQL schema and optionally queries for each model. You can\nalso specify additional models such as vendor/packages models to be included.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require always-open/laravel-graphql-schema-generator\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"laravel-graphql-schema-generator-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    'custom_type_mappings' =\u003e [\n         'timestamp' =\u003e 'DateTime',\n         'datetime'  =\u003e 'DateTime',\n         'date'      =\u003e 'Date',\n    ],\n\n    'custom_scalar_definitions' =\u003e [\n        'scalar Date @scalar(class: \"Nuwave\\\\Lighthouse\\\\Schema\\\\Types\\\\Scalars\\\\Date\")',\n        'scalar DateTime @scalar(class: \"Nuwave\\\\Lighthouse\\\\Schema\\\\Types\\\\Scalars\\\\DateTime\")',\n    ],\n\n    'model_path' =\u003e app_path('Models'),\n\n    'model_stub' =\u003e __DIR__ . '/../stubs/graphql_schema.stub',\n\n    'schema_path' =\u003e app_path('../graphql'),\n];\n```\n\n## Usage\n\n### Basic/default usage\n\nThis command will output the GraphQL schema to the `schema_path` specified in the config file. It will only generate the \nschema file and will only parse the models in the `model_path` specified in the config file.\n\n```bash\nphp artisan laravel-graphql-generator:create-schema\n```\n\n### Outputting queries\n\nTo also add queries to the schema, pass the `--include-queries` flag. This will generate a GraphQL schema file and query\nfiles for each model in the `model_path` specified in the config file.\n\n```bash\nphp artisan laravel-graphql-generator:create-schema --include-queries\n```\n\n### Adding additional models\n\nIf there are additional models that exist outside of the `model_path` that you want to include, you can pass the \n`--additional-models` flag. This is very useful if you have vendor/package models that you want to include.\n\n```bash\nphp artisan laravel-graphql-generator:create-schema --additional-models=\"\\\\Spatie\\\\Tags\\\\Tag\"\n```\n\nYou can also pass in a comma separated list of models to include.\n\n```bash\nphp artisan laravel-graphql-generator:create-schema --additional-models=\"\\\\Spatie\\\\Tags\\\\Tag\",\"\\\\Spatie\\\\Activitylog\\\\Models\\\\Activity\"\n```\n \n\n### Adding additional query properties\n\nThe default queries will be created using primary keys and unique indices. If you want to add additional properties to \nsearch you can pass them in using the `--additional-query-properties` flag. It will be applied to every model that has \nthe specified property.\n\nThis command could add queries using the properties `key` and `name`. Support for multiple fields isn't supported by the \npass in as of this version.\n\n```bash\nphp artisan laravel-graphql-generator:create-schema --additional-query-properties=key,name\n```\n\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/qschmick/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [quentin.schmick](https://github.com/qschmick)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falways-open%2Flaravel-graphql-schema-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falways-open%2Flaravel-graphql-schema-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falways-open%2Flaravel-graphql-schema-generator/lists"}