Go to file
Hiram Chirino 4cf7956ff5
feat: add cockroachdb support. (#50)
This PR changes the generated SQL so that it's also compatible with CockroachDB.
Notable changes:
* use `SELECT to_jsonb("__sr_0".*)`  instead of `SELECT to_jsonb("__sr_0")`
* don't use `json_populate_record`, use the `CAST` and `->>` instead.  For example:

  instead of: `SELECT "t"."full_name", "t"."email" FROM "_sg_input" i, json_populate_record(NULL::users, i.j) t`

  do: `CAST( i.j ->>'full_name' AS character varying), CAST( i.j ->>'email' AS character varying) FROM "_sg_input" i`

This PR also adds some integration tests against an actual database instance.  If you have the cockroachdb binary installed on your PATH,
the test suite will startup a temporary cockroachdb instance on a random port to test against.  It is stopped and the tmp data files are deleted once the test ends.  It will also run the integration tests against database
pointed at by your `SG_POSTGRESQL_TEST_URL` environment variable if it’s set.

Also includes some small formatting changes introduced by `gofmt -w .`
2020-04-18 17:42:17 -04:00
.chglog Add a CHANGLOG.md 2019-11-29 00:14:05 -05:00
.github/ISSUE_TEMPLATE Update issue templates 2019-12-01 01:25:39 -05:00
config Fix issue with relative paths and config files 2020-04-17 10:56:26 -04:00
core feat: add cockroachdb support. (#50) 2020-04-18 17:42:17 -04:00
docs Fix issue with relative paths and config files 2020-04-17 10:56:26 -04:00
examples/rails-app fix "Try the demo app" in docs (#38) 2020-02-24 02:02:22 +05:30
internal Fix issue with relative paths and config files 2020-04-17 10:56:26 -04:00
jsn Refactor Super Graph into a library #26 2020-04-10 02:27:43 -04:00
.dockerignore Improve the demo experience 2019-04-11 01:10:51 -04:00
.gitignore Fix issue with make install 2020-04-12 20:35:31 -04:00
.wtc.yaml Make go get to install work. 2020-04-16 00:26:32 -04:00
CHANGELOG.md Fix documentation for DB relationships 2019-12-10 00:03:44 -05:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2019-12-01 00:13:04 -05:00
CONTRIBUTING.md Update CONTRIBUTING.md 2019-12-01 01:17:27 -05:00
demo rails-app moved to examples folder 2019-10-05 00:49:39 -04:00
docker-compose.yml Fix issue with upgrading to postgres 12 docker image #36 2020-02-24 02:37:21 +05:30
Dockerfile Make go get to install work. 2020-04-16 00:26:32 -04:00
fuzzbuzz.yaml Add migrate command 2019-09-26 00:35:31 -04:00
go.mod feat: add cockroachdb support. (#50) 2020-04-18 17:42:17 -04:00
go.sum feat: add cockroachdb support. (#50) 2020-04-18 17:42:17 -04:00
LICENSE Move license from MIT to Apache 2.0. Add Makefile 2019-11-28 01:25:46 -05:00
main.go Make go get to install work. 2020-04-16 00:26:32 -04:00
Makefile Make go get to install work. 2020-04-16 00:26:32 -04:00
NOTICE Move license from MIT to Apache 2.0. Add Makefile 2019-11-28 01:25:46 -05:00
README.md Fix readme add library usage 2020-04-11 16:41:10 -04:00

Build web products faster. Secure high performance GraphQL

GoDoc Apache 2.0 Docker build Cloud native Discord Chat

What's Super Graph?

Designed to 100x your developer productivity. Super Graph will instantly and without you writing code provide you a high performance GraphQL API for Postgres DB. GraphQL queries are compiled into a single fast SQL query. Super Graph is a GO library and a service, use it in your own code or run it as a seperate service.

Using it as a service

git clone https://github.com/dosco/super-graph 
cd ./super-graph
make install

super-graph new <app_name>

Using it in your own code

package main

import (
  "database/sql"
  "fmt"
  "time"
  "github.com/dosco/super-graph/core"
  _ "github.com/jackc/pgx/v4/stdlib"
)

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

  conf, err := core.ReadInConfig("./config/dev.yml")
  if err != nil {
    log.Fatalf(err)
  }

  sg, err = core.NewSuperGraph(conf, db)
  if err != nil {
    log.Fatalf(err)
  }

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

  res, err := sg.GraphQL(context.Background(), query, nil)
  if err != nil {
    log.Fatalf(err)
  }

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

About Super Graph

After working on several products through my career I find that we spend way too much time on building API backends. Most APIs also require constant updating, this costs real 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 Super Graph 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

  • Complex nested queries and mutations
  • 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
  • Works with Postgres and YugabyteDB

Documentation

supergraph.dev

Contact me

I'm happy to help you deploy Super Graph so feel free to reach out over Twitter or Discord.

twitter/dosco

chat/super-graph

License

Apache Public License 2.0

Copyright (c) 2019-present Vikram Rangnekar