{"id":18930110,"url":"https://github.com/labd/schema-generate","last_synced_at":"2025-04-15T15:31:17.644Z","repository":{"id":43885078,"uuid":"339736107","full_name":"labd/schema-generate","owner":"labd","description":"A library and CLI tool to generate various schemas based off of TypeScript interfaces.","archived":false,"fork":false,"pushed_at":"2022-07-08T12:57:27.000Z","size":255,"stargazers_count":5,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T23:18:32.863Z","etag":null,"topics":["amplience","graphql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/labd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-17T13:41:38.000Z","updated_at":"2021-12-08T15:00:26.000Z","dependencies_parsed_at":"2022-08-28T13:41:18.318Z","dependency_job_id":null,"html_url":"https://github.com/labd/schema-generate","commit_stats":null,"previous_names":["korsvanloon/schema-generate"],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fschema-generate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fschema-generate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fschema-generate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labd%2Fschema-generate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labd","download_url":"https://codeload.github.com/labd/schema-generate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249097904,"owners_count":21212373,"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":["amplience","graphql","typescript"],"created_at":"2024-11-08T11:36:33.986Z","updated_at":"2025-04-15T15:31:17.011Z","avatar_url":"https://github.com/labd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Schema Generate\n\nThis repository can generate schema files based on Typescript files containing interfaces.\n\nCurrently it only supports GraphQL types.\n\n## GraphQL\n\nThe GraphQL schema generator takes Typescript files with interfaces as input and generates GraphQL types as a result.\n\nFor example, given the following file called `books.ts`.\n```ts\nexport type CustomScalar = string \u0026 {__scalar?: undefined}\nexport interface Author {\n    name: string\n    custom: CustomScalar\n}\nexport interface Chapter {\n    startPage: number\n}\nexport interface Book {\n    id: string\n    author: Author\n    title: string\n    subTitle?: string\n    /** @float */\n    pages: number\n    chapters: Chapter[]\n}\nexport interface Game {\n    title: string\n}\nexport type Product = Book | Game\n```\n\nYou can generate the following GraphQL types:\n\n```graphql\nscalar CustomScalar\nunion Product = Book | Game\ntype Author {\n    name: String!\n    custom: CustomScalar!\n}\ntype Chapter {\n    startPage: Int!\n}\ntype Book {\n    id: ID!\n    author: Author!\n    title: String!\n    subTitle: String\n    pages: Float!\n    chapters: [Chapter!]!\n}\ntype Product {\n    title: String!\n}\n```\n\nEither by using the CLI\n\n```bash\nyarn schema-generate graphql books.ts\n# or\nyarn schema-generate graphql books.ts -o schema.graphql\n```\n\nOr calling the function directly\n\n```ts\nimport { generateGraphqlTypes } from 'schema-generate/graphql'\n\nconst graphqlTypeString = generateGraphqlTypes(['books.ts'])\n```\n\n# How to release\n\nFirst increase the version in package.json, then use that version to create a release with that number in Github.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fschema-generate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabd%2Fschema-generate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabd%2Fschema-generate/lists"}