{"id":22122081,"url":"https://github.com/drizzle-team/drizzle-graphql","last_synced_at":"2025-05-12T17:13:34.533Z","repository":{"id":229962086,"uuid":"774545080","full_name":"drizzle-team/drizzle-graphql","owner":"drizzle-team","description":"Automatically generate GraphQL schema or customizable schema config fields from Drizzle ORM schema","archived":false,"fork":false,"pushed_at":"2024-08-12T16:41:56.000Z","size":725,"stargazers_count":70,"open_issues_count":19,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-08T05:29:00.719Z","etag":null,"topics":["drizzle-orm","graphql","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/drizzle-graphql","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drizzle-team.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-19T18:26:36.000Z","updated_at":"2025-04-24T05:19:51.000Z","dependencies_parsed_at":"2024-03-27T05:24:58.347Z","dependency_job_id":"c0ce7f9c-8b61-4218-9b3c-477c8b937ec2","html_url":"https://github.com/drizzle-team/drizzle-graphql","commit_stats":{"total_commits":55,"total_committers":4,"mean_commits":13.75,"dds":"0.10909090909090913","last_synced_commit":"c558249fadcc7bd1af8ec17faf292d8cf2d365c5"},"previous_names":["sukairo-02/drizzle-graphql"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drizzle-team%2Fdrizzle-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drizzle-team%2Fdrizzle-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drizzle-team%2Fdrizzle-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drizzle-team%2Fdrizzle-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drizzle-team","download_url":"https://codeload.github.com/drizzle-team/drizzle-graphql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253765588,"owners_count":21960760,"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":["drizzle-orm","graphql","nodejs","typescript"],"created_at":"2024-12-01T15:17:16.488Z","updated_at":"2025-05-12T17:13:34.491Z","avatar_url":"https://github.com/drizzle-team.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Drizzle-GraphQL\r\n\r\nAutomatically create GraphQL schema or customizable schema config fields from Drizzle ORM schema\r\n\r\n## Usage\r\n\r\n-   Pass your drizzle database instance and schema into builder to generate `{ schema, entities }` object\r\n-   Use `schema` if pre-built schema already satisfies all your neeeds. It's compatible witn any server that consumes `GraphQLSchema` class instance\r\n\r\n    Example: hosting schema using [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server)\r\n\r\n    ```Typescript\r\n    import { createServer } from 'node:http'\r\n    import { createYoga } from 'graphql-yoga'\r\n    import { buildSchema } from 'drizzle-graphql'\r\n\r\n    // db - your drizzle instance\r\n    import { db } from './database'\r\n\r\n    const { schema } = buildSchema(db)\r\n\r\n    const yoga = createYoga({ schema })\r\n\r\n    server.listen(4000, () =\u003e {\r\n        console.info('Server is running on http://localhost:4000/graphql')\r\n    })\r\n    ```\r\n\r\n-   If you want to customize your schema, you can use `entities` object to build your own new schema\r\n\r\n    ```Typescript\r\n    import { createServer } from 'node:http'\r\n    import { GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLSchema } from 'graphql'\r\n    import { createYoga } from 'graphql-yoga'\r\n    import { buildSchema } from 'drizzle-graphql'\r\n\r\n    // Schema contains 'Users' and 'Customers' tables\r\n    import { db } from './database'\r\n\r\n    const { entities } = buildSchema(db)\r\n\r\n    // You can customize which parts of queries or mutations you want\r\n    const schema = new GraphQLSchema({\r\n        query: new GraphQLObjectType({\r\n            name: 'Query',\r\n            fields: {\r\n                // Select only wanted queries out of all generated\r\n                users: entities.queries.users,\r\n                customer: entities.queries.customersSingle,\r\n\r\n                // Create a custom one\r\n                customUsers: {\r\n                    // You can reuse and customize types from original schema\r\n                    type: new GraphQLList(new GraphQLNonNull(entities.types.UsersItem)),\r\n                    args: {\r\n                        // You can reuse inputs as well\r\n                        where: {\r\n                            type: entities.inputs.UsersFilters\r\n                        }\r\n                    },\r\n                    resolve: async (source, args, context, info) =\u003e {\r\n                        // Your custom logic goes here...\r\n                        const result = await db.select(schema.Users).where()...\r\n\r\n                        return result\r\n                    }\r\n                }\r\n            }\r\n        }),\r\n        // Same rules apply to mutations\r\n        mutation: new GraphQLObjectType({\r\n            name: 'Mutation',\r\n            fields: entities.mutations\r\n        }),\r\n        // In case you need types inside your schema\r\n        types: [...Object.values(entities.types), ...Object.values(entities.inputs)]\r\n    })\r\n\r\n    const yoga = createYoga({\r\n        schema\r\n    })\r\n\r\n    server.listen(4000, () =\u003e {\r\n        console.info('Server is running on http://localhost:4000/graphql')\r\n    })\r\n    ```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrizzle-team%2Fdrizzle-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrizzle-team%2Fdrizzle-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrizzle-team%2Fdrizzle-graphql/lists"}