{"id":15031755,"url":"https://github.com/jensneuse/goprisma","last_synced_at":"2025-04-09T21:23:10.806Z","repository":{"id":57588113,"uuid":"372430182","full_name":"jensneuse/goprisma","owner":"jensneuse","description":"A Go wrapper for prisma to turn databases into GraphQL APIs using Go.","archived":false,"fork":false,"pushed_at":"2022-03-02T08:21:32.000Z","size":227499,"stargazers_count":72,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-23T23:15:25.657Z","etag":null,"topics":["golang","golang-library","golang-package","golang-wrapper","graphql","prisma","prisma-binding","prisma-client","prisma2","rust","rust-lang","rustlang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/jensneuse.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-05-31T08:06:57.000Z","updated_at":"2024-06-02T22:15:12.000Z","dependencies_parsed_at":"2022-09-14T15:30:36.809Z","dependency_job_id":null,"html_url":"https://github.com/jensneuse/goprisma","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensneuse%2Fgoprisma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensneuse%2Fgoprisma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensneuse%2Fgoprisma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jensneuse%2Fgoprisma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jensneuse","download_url":"https://codeload.github.com/jensneuse/goprisma/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113043,"owners_count":21049771,"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":["golang","golang-library","golang-package","golang-wrapper","graphql","prisma","prisma-binding","prisma-client","prisma2","rust","rust-lang","rustlang"],"created_at":"2024-09-24T20:16:29.238Z","updated_at":"2025-04-09T21:23:10.785Z","avatar_url":"https://github.com/jensneuse.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoPrisma - a Go wrapper for the Prisma Engines\n\n## What's this?\n\nIntrospect a database and use it as a GraphQL API using Go.\n\nSupported Databases:\n- [x] SQLite\n- [x] PostgreSQL\n- [x] MySQL\n- [x] MongoDB\n- [x] MS SQL Server\n- [ ] CockroachDB\n\n## How to use this in production?\n\nIt might be obvious, but I just want to make it clear that you should NOT publicly expose your database with this library.\nThis is only intended for use cases where the GraphQL API is shielded by some other component.\n\nWe're using goprisma internally in WunderGraph which adds such a shielding layer,\nwith authentication, authorization, role-based access control, caching and more.\n\nAdditionally, WunderGraph comes with a TypeScript SDK,\nso you can introspect multiple databases as well as GraphQL and REST APIs and join them together.\n\nCheck out [WunderGraph if you're interested in a production-grade solution](https://wundergraph.com).\nHere's a link to the [docs on all supported DataSources](https://wundergraph.com/docs/overview/datasources/overview).\n\nOtherwise, feel free to use this as a go package in your own projects.\n\n### go get\n\n```shell\ngo get github.com/jensneuse/goprisma\n```\n\n### Introspect a database\n\n```go\nprismaSchema := \"datasource db {provider = \\\"postgresql\\\" url = \\\"postgresql://admin:admin@localhost:54321/example?schema=public\u0026connection_limit=20\u0026pool_timeout=5\\\"}\"\nschema, sdl, err := Introspect(prismaSchema)\n```\n\n### Make a Query\n\n```go\nquery := \"{\\\"query\\\": \\\"query Messages {findManymessages(take: 20 orderBy: [{id: desc}]){id message users {id name}}}\",\"variables\\\": {}}\"\nengine, err := NewEngine(schema)\nif err != nil {\n\treturn\n}\ndefer engine.Close()\nresponse := engine.Execute(query)\n```\n\n## Why?\n\nGraphQL is a nice abstraction layer on top of other APIs.\nMaking databases available can be a productivity gainer when no direct database access is required and GraphQL clients already exist in the codebase.\n\n## How does it work\n\nPrisma is a really powerful ORM.\nIf you look closely, you'll realize that internally,\nPrisma 2 is powered by a GraphQL Engine to abstract away the database layer.\n\nThe GraphQL Engine is written in Rust.\n\nThis library is a CGO wrapper to make the Prisma Rust GraphQL Engine available to write Go programs on top of it.\n\n## Is it fast?\n\nI've measured ~0.3ms latency (Go -\u003e Rust -\u003e Database -\u003e Go) on my laptop using a database in docker.\n\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/jensneuse/goprisma/pkg/prisma\ncpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz\nBenchmarkEngine_Execute\nBenchmarkEngine_Execute-16    \t   43815\t    304507 ns/op\t     144 B/op\t       3 allocs/op\nPASS\n```\n\nYou can find the benchmark in the prisma package tests and run it yourself.\n\n## What architectures are supported?\n\n- [x] darwin x86_64\n- [x] darwin aarch64\n- [x] linux x86_64\n- [ ] windows x86_64 (needs verification)\n\nOther targets can be added.\n\n## Where is the Rust wrapper?\n\nhttps://github.com/jensneuse/prisma-engines/tree/goprisma\n\n## Example / How to run the tests?\n\nFirst, clone the repo.\n\n```shell\ncd docker-example\ndocker-compose up\n```\n\nNow you're able to run the tests.\n\n## How can you help?\n\n### Testing\n\nYou can help by running the tests and architectures that need verification.\nPlease report any issues and tell me if it works.\n\n### Automate building the C-Wrapper\n\nYou might want to increase the level of trust by adding a github action to automate building the Rust C-Wrapper.\nCurrently, I'm building it on my MacBook.\n\nIdeally, this github action would fetch the latest stable of prisma-engines, compile the C-Wrapper and updates the lib folder via PR.\nA blueprint how to do this can be found here: https://github.com/rogchap/v8go/blob/master/.github/workflows/v8build.yml\n\nIf you're interested in adding this, please open a PR.\nThat said, you can always build the Rust part yourself to increase the level of trust.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjensneuse%2Fgoprisma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjensneuse%2Fgoprisma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjensneuse%2Fgoprisma/lists"}