graphjin

command module
v0.15.57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

README

GraphJin - Fetch data with GraphQL

GoDoc GoReport Apache 2.0 Docker build Discord Chat

GraphJin gives you a high performance GraphQL API without you having to write any code. GraphQL is automagically compiled into an efficient SQL query. Use it either as a library or a standalone service.

Using it as a service

go get github.com/dosco/graphjin
graphjin new <app_name>

cd <app_name>
docker-compose run api db:setup
docker-compose up

Using it in your own code

go get github.com/dosco/graphjin/core
package main

import (
  "context"
  "database/sql"
  "fmt"
  "log"

  "github.com/dosco/graphjin/core"
  _ "github.com/jackc/pgx/v4/stdlib"
)

func main() {
  db, err := sql.Open("pgx", "postgres://postgres:@localhost:5432/example_db")
  if err != nil {
    log.Fatal(err)
  }

  sg, err := core.NewGraphJin(nil, db)
  if err != nil {
    log.Fatal(err)
  }

  query := `
    query {
      posts {
      id
      title
    }
  }`

  ctx := context.Background()
  ctx = context.WithValue(ctx, core.UserIDKey, 1)

  res, err := sg.GraphQL(ctx, query, nil)
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(string(res.Data))
}

About GraphJin

After working on several products through my career I found that we spend way too much time on building API backends. Most APIs also need constant updating, and this costs time and money.

It's always the same thing, figure out what the UI needs then build an endpoint for it. Most API code involves struggling with an ORM to query a database and mangle the data into a shape that the UI expects to see.

I didn't want to write this code anymore, I wanted the computer to do it. Enter GraphQL, to me it sounded great, but it still required me to write all the same database query code.

Having worked with compilers before I saw this as a compiler problem. Why not build a compiler that converts GraphQL to highly efficient SQL.

This compiler is what sits at the heart of GraphJin, with layers of useful functionality around it like authentication, remote joins, rails integration, database migrations, and everything else needed for you to build production-ready apps with it.

Features

  • Works with Postgres, MySQL8 and Yugabyte DB
  • Complex nested queries and mutations
  • Realtime updates with subscriptions
  • Build infinite scroll, feeds, nested comments, etc
  • Auto learns database tables and relationships
  • Role and Attribute-based access control
  • Opaque cursor-based efficient pagination
  • Full-text search and aggregations
  • JWT tokens supported (Auth0, etc)
  • Join database queries with remote REST APIs
  • Also works with existing Ruby-On-Rails apps
  • Rails authentication supported (Redis, Memcache, Cookie)
  • A simple config file
  • High performance Go codebase
  • Tiny docker image and low memory requirements
  • Fuzz tested for security
  • Database migrations tool
  • Database seeding tool
  • OpenCensus Support: Zipkin, Prometheus, X-Ray, Stackdriver
  • API Rate Limiting
  • Highly scalable and fast

Documentation

graphjin.com

Reach out

We're happy to help you leverage GraphJin reach out if you have questions

Twitter

Chat

Production use

The popular 42papers.com site for discovering trending papers in AI and Computer Science uses GraphJin for it's entire backend.

License

Apache Public License 2.0

Copyright (c) 2019-present Vikram Rangnekar

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
auth module
cmd module
conf module
Package core provides the primary API to include and use GraphJin with your own code.
Package core provides the primary API to include and use GraphJin with your own code.
internal/crypto
Provides symmetric authenticated encryption using 256-bit AES-GCM with a random nonce.
Provides symmetric authenticated encryption using 256-bit AES-GCM with a random nonce.
internal
serv
Package reload offers lightweight automatic reloading of running processes.
Package reload offers lightweight automatic reloading of running processes.
Package jsn provides fast and no-allocation functions to extract values and modify JSON data
Package jsn provides fast and no-allocation functions to extract values and modify JSON data
plugin
afero Module
osfs Module
otel Module
wasm Module
serv module
tests module
wasm module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL