Skip to content

Generates a graphql schema based on a database's schema.

License

Notifications You must be signed in to change notification settings

NathanLapp/db-to-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

db-to-graphql

A graphql schema generator that uses the schema(s) of a database to generate a graphql schema.

Currently supported databases

  • Oracle

Current implementation of the graphql spec

  • Oracle
    • Read only
    • AND filtering

Getting Started

A database and database user must already be created. What tables and database schema(s) are made available to graphQL depends on the select permissions of the used database user. For further refinement, one or more database schemas can be specified as an optional parameter.

Using db-to-graphql

Install db-to-graphql

using npm:

npm install --save db-to-graphql

Using this package:

var dbToGraphql = require('db-to-graphql');

const DB_CONNECTION = {
  user: 'user',
  password: 'pass',
  connectionString: 'hostname:port/sid'
};

dbToGraphql.generateGraphQL(DB_CONNECTION, 'Oracle')
.then(function(generatedGraphql) {
  let {root, schema} = generatedGraphql;
})
.catch((err) => {
  console.log(err);
});

If you want to restrict which schemas are used for graphql and don't want to modify the permissions for the database user:

dbToGraphql.generateGraphQL(DB_CONNECTION, 'Oracle', ['SCHEMA1', 'SCHEMA2'])

Dependencies

Contributing

I encourage contribution especially with supporting more databases.

Changelog

Changes are tracked as GitHub releases.

License

db-to-graphql is MIT-licensed.

About

Generates a graphql schema based on a database's schema.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published