-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for mysql2 and pg-pool nodejs db clients
- Loading branch information
Showing
20 changed files
with
826 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import graphjin from "graphjin"; | ||
import express from "express"; | ||
import http from "http"; | ||
import mysql from "mysql2" | ||
|
||
const pool = mysql.createPool({ | ||
host: 'localhost', | ||
port: '/tmp/mysql.sock', | ||
user: 'root', | ||
database: 'db', | ||
waitForConnections: true, | ||
connectionLimit: 10, | ||
queueLimit: 0 | ||
}); | ||
|
||
const db = pool.promise(); | ||
const app = express(); | ||
const server = http.createServer(app); | ||
|
||
// config can either be a filename (eg. `dev.yml`) or an object | ||
const config = { | ||
production: false, | ||
db_type: "mysql", | ||
disable_allow_list: true | ||
}; | ||
|
||
const gj = await graphjin("./config", config, db); | ||
|
||
|
||
const res1 = await gj.subscribe( | ||
"subscription getUpdatedUser { users(id: $userID) { id email } }", | ||
null, | ||
{ userID: 2 }) | ||
|
||
res1.data(function(res) { | ||
console.log(">", res.data()) | ||
}) | ||
|
||
app.get('/', async function(req, resp) { | ||
const res2 = await gj.query( | ||
"query getUser { users(id: $id) { id email } }", | ||
{ id: 1 }, | ||
{ userID: 1 }) | ||
|
||
resp.send(res2.data()); | ||
}); | ||
|
||
server.listen(3000); | ||
console.log('Express server started on port %s', server.address().port); |
Oops, something went wrong.
5350d7f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
graphjin – ./
graphjin-git-master-dosco.vercel.app
graphjin-dosco.vercel.app
graphjin.com
graphjin.vercel.app
www.graphjin.com