All Projects β†’ jensneuse β†’ goprisma

jensneuse / goprisma

Licence: Apache-2.0 License
A Go wrapper for prisma to turn databases into GraphQL APIs using Go.

Programming Languages

go
31211 projects - #10 most used programming language
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to goprisma

nestjs-prisma-starter
Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker
Stars: ✭ 1,107 (+1950%)
Mutual labels:  prisma, prisma-client, prisma2
nestjs-prisma-docker
Dockerizing a NestJS app with Prisma and PostgreSQL
Stars: ✭ 42 (-22.22%)
Mutual labels:  prisma, prisma2
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+33544.44%)
Mutual labels:  prisma, prisma-client
nest-prisma-rest-api-boilerplate
Nest + Prisma + TypeScript | REST API Starter repository
Stars: ✭ 24 (-55.56%)
Mutual labels:  prisma, prisma2
gql2sql
GraphQL to SQL service example
Stars: ✭ 31 (-42.59%)
Mutual labels:  prisma-client, prisma2
Prisma Examples
πŸš€ Ready-to-run Prisma example projects
Stars: ✭ 3,017 (+5487.04%)
Mutual labels:  prisma, prisma-client
prisma-json-schema-generator
A generator for Prisma 2 to generate a valid JSON Schema (v7)
Stars: ✭ 145 (+168.52%)
Mutual labels:  prisma, prisma2
prisma-pg-jest
Example showcasing how to use Prisma + Postgres + Jest, where each test has its own unique DB context
Stars: ✭ 103 (+90.74%)
Mutual labels:  prisma, prisma2
database-schema-examples
Database Schema Examples we strive to support in Prisma
Stars: ✭ 94 (+74.07%)
Mutual labels:  prisma, prisma2
blitz
⚑️The Fullstack React Framework β€” built on Next.js
Stars: ✭ 11,558 (+21303.7%)
Mutual labels:  prisma, prisma2
praxis
Social networking platform built with Next.js, Apollo GraphQL, and Prisma
Stars: ✭ 37 (-31.48%)
Mutual labels:  prisma
cadhub
We're out to raise awareness and put CodeCAD on the map. The success of CadHub can be measured by the amount it promotes the use of CodeCAD within the mechanical/manufacturing industry and the strength the CadHub community.
Stars: ✭ 204 (+277.78%)
Mutual labels:  prisma
bot
🎲 A general purpose utility bot, with an economy, games, and lots of other features.
Stars: ✭ 95 (+75.93%)
Mutual labels:  prisma
prettier-plugin-prisma
Prettier plugin for Prisma
Stars: ✭ 102 (+88.89%)
Mutual labels:  prisma
boilerplate
Fullstack boilerplate using Typescript, React, Node & GraphQL
Stars: ✭ 738 (+1266.67%)
Mutual labels:  prisma
fastify-prisma
Basic Fastify app using Prisma as an ORM
Stars: ✭ 26 (-51.85%)
Mutual labels:  prisma
craftql
A CLI tool to visualize GraphQL schemas and to output a graph data structure as a graphviz .dot format
Stars: ✭ 75 (+38.89%)
Mutual labels:  rustlang
gin-rest-prisma-boilerplate
🍱 backend with gin (golang web framework), redis, prisma, rbac, and authentication
Stars: ✭ 25 (-53.7%)
Mutual labels:  prisma
nextjs-graphql-adminpanel
Admin panel built with NextJS(Typescript), Material UI, Apollo Client & GraphQL. In the backend, Prisma 2 with Nexus and Mysql is used.
Stars: ✭ 119 (+120.37%)
Mutual labels:  prisma
node-express-prisma-v1-official-app
Official real world application built with Node + Express + Typescript + Prisma
Stars: ✭ 24 (-55.56%)
Mutual labels:  prisma

GoPrisma - a Go wrapper for the Prisma Engines

What's this?

Introspect a database and use it as a GraphQL API using Go.

Supported Databases:

  • SQLite
  • PostgreSQL
  • MySQL
  • MongoDB
  • MS SQL Server

go get

go get github.com/jensneuse/goprisma

Introspect a database

prismaSchema := "datasource db {provider = \"postgresql\" url = \"postgresql://admin:admin@localhost:54321/example?schema=public&connection_limit=20&pool_timeout=5\"}"
schema, sdl, err := Introspect(prismaSchema)

Make a Query

query := "{\"query\": \"query Messages {findManymessages(take: 20 orderBy: [{id: desc}]){id message users {id name}}}","variables\": {}}"
engine, err := NewEngine(schema)
if err != nil {
	return
}
defer engine.Close()
response := engine.Execute(query)

Why?

GraphQL is a nice abstraction layer on top of other APIs. Making databases available can be a productivity gainer when no direct database access is required and GraphQL clients already exist in the codebase.

How does it work

Prisma is a really powerful ORM. If you look closely, you'll realize that internally, Prisma 2 is powered by a GraphQL Engine to abstract away the database layer.

The GraphQL Engine is written in Rust.

This library is a CGO wrapper to make the Prisma Rust GraphQL Engine available to write Go programs on top of it.

Is it fast?

I've measured ~0.3ms latency (Go -> Rust -> Database -> Go) on my laptop using a database in docker.

goos: darwin
goarch: amd64
pkg: github.com/jensneuse/goprisma/pkg/prisma
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkEngine_Execute
BenchmarkEngine_Execute-16    	   43815	    304507 ns/op	     144 B/op	       3 allocs/op
PASS

You can find the benchmark in the prisma package tests and run it yourself.

What architectures are supported?

  • darwin x86_64
  • darwin aarch64
  • linux x86_64
  • windows x86_64 (needs verification)

Other targets can be added.

Where is the Rust wrapper?

https://github.com/jensneuse/prisma-engines/tree/goprisma

Example / How to run the tests?

First, clone the repo.

cd docker-example
docker-compose up

Now you're able to run the tests.

How can you help?

Testing

You can help by running the tests and architectures that need verification. Please report any issues and tell me if it works.

Automate building the C-Wrapper

You might want to increase the level of trust by adding a github action to automate building the Rust C-Wrapper. Currently, I'm building it on my MacBook.

Ideally, this github action would fetch the latest stable of prisma-engines, compile the C-Wrapper and updates the lib folder via PR. A blueprint how to do this can be found here: https://github.com/rogchap/v8go/blob/master/.github/workflows/v8build.yml

If you're interested in adding this, please open a PR.

Considerations

It might be obvious, but I just want to make it clear that you should NOT publicly expose your database with this library. This is only intended for use cases where the GraphQL API is shielded by some other component.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].