graphjin 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -30
- package/package.json +9 -14
- package/wasm/config/dev.yml +128 -0
- package/wasm/config/prod.yml +21 -0
- package/wasm/graphjin.wasm +0 -0
- package/wasm/{globals.js → js/globals.js} +0 -0
- package/wasm/{graphjin.js → js/graphjin.js} +3 -2
- package/wasm/js/install.js +27 -0
- /package/wasm/{runtime → js}/wasm_exec.js +0 -0
package/README.md
CHANGED
|
@@ -9,39 +9,12 @@
|
|
|
9
9
|
<!-- [](https://deploy.cloud.run)
|
|
10
10
|
-->
|
|
11
11
|
|
|
12
|
-
GraphJin gives you an instant secure and fast GraphQL API without code. Just use a GraphQL query to define your API and GraphJin automagically converts it into a full featured API. Build your backend APIs 100X faster.
|
|
13
|
-
|
|
14
|
-
Works with NodeJS and GO. Supports several databases, Postgres, MySQL, YugabyteDB Cockroach, etc.
|
|
15
|
-
|
|
16
|
-
## Quick install
|
|
17
|
-
|
|
18
|
-
NPM
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
npm install graphjin
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Mac (Homebrew)
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
brew install dosco/graphjin/graphjin
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Ubuntu (Snap)
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
sudo snap install --classic graphjin
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Debian and Redhat ([releases](https://github.com/dosco/graphjin/releases))
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
Download the .deb or .rpm from the releases page and install with dpkg -i and rpm -i respectively.
|
|
40
|
-
```
|
|
12
|
+
GraphJin gives you an instant secure and fast GraphQL API without code. Just use a GraphQL query to define your API and GraphJin automagically converts it into a full featured API. Build your backend APIs **100X** faster. Works with **NodeJS** and **GO**. Supports several databases, **Postgres**, **MySQL**, **YugabyteDB**, **Cockroach**, etc.
|
|
41
13
|
|
|
42
14
|
## Secure out of the box
|
|
43
15
|
|
|
44
|
-
|
|
16
|
+
In production all queries are always read from locally saved copies not from what the client sends hence clients cannot modify the query. This makes
|
|
17
|
+
GraphJin very secure as its similiar to building APIs by hand. The idea that GraphQL means that clients can change the query as they wish **does not** apply to GraphJin
|
|
45
18
|
|
|
46
19
|
---
|
|
47
20
|
|
|
@@ -108,6 +81,32 @@ console.log("Express server started on port %s", server.address().port);
|
|
|
108
81
|
|
|
109
82
|
## Use with GO / Standalone service
|
|
110
83
|
|
|
84
|
+
### Quick install
|
|
85
|
+
|
|
86
|
+
Mac (Homebrew)
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
brew install dosco/graphjin/graphjin
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Ubuntu (Snap)
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
sudo snap install --classic graphjin
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Debian and Redhat ([releases](https://github.com/dosco/graphjin/releases))
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
Download the .deb or .rpm from the releases page and install with dpkg -i and rpm -i respectively.
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
NPM
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
npm install graphjin
|
|
108
|
+
```
|
|
109
|
+
|
|
111
110
|
### Quickly create and deploy new apps
|
|
112
111
|
|
|
113
112
|
```bash
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphjin",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "GraphJin - Build APIs in 5 minutes with GraphQL
|
|
3
|
+
"version": "2.0.5",
|
|
4
|
+
"description": "GraphJin - Build APIs in 5 minutes with GraphQL",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "wasm/graphjin.js",
|
|
6
|
+
"main": "wasm/js/graphjin.js",
|
|
7
7
|
"files": [
|
|
8
|
+
"./wasm/config",
|
|
9
|
+
"./wasm/runtime",
|
|
8
10
|
"./wasm/graphjin.wasm",
|
|
9
|
-
"./wasm/*.js"
|
|
10
|
-
"./wasm/runtime"
|
|
11
|
+
"./wasm/js/*.js"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
|
-
"postinstall": "
|
|
14
|
-
"preuninstall": "go-npm uninstall"
|
|
14
|
+
"postinstall": "node ./wasm/js/install.js"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -29,12 +29,7 @@
|
|
|
29
29
|
"url": "https://github.com/dosco/graphjin/issues"
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/dosco/graphjin#readme",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"path": "./bin",
|
|
35
|
-
"url": "https://github.com/dosco/graphjin/releases/download/v{{version}}/graphjin_{{version}}_{{platform}}_{{arch}}.tar.gz"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@go-task/cli": "^3.16.0"
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"fs-extra": "^11.1.0"
|
|
39
34
|
}
|
|
40
35
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# When production mode is 'true' only queries
|
|
2
|
+
# from the allow list are permitted.
|
|
3
|
+
production: false
|
|
4
|
+
|
|
5
|
+
# Secret key for general encryption operations like
|
|
6
|
+
# encrypting the cursor data
|
|
7
|
+
secret_key: supercalifajalistics
|
|
8
|
+
|
|
9
|
+
# Subscriptions poll the database to query for updates
|
|
10
|
+
# this sets the duration (in seconds) between requests.
|
|
11
|
+
# Defaults to 5 seconds
|
|
12
|
+
subs_poll_every_seconds: 5
|
|
13
|
+
|
|
14
|
+
# Default limit value to be used on queries and as the max
|
|
15
|
+
# limit on all queries where a limit is defined as a query variable.
|
|
16
|
+
# Defaults to 20
|
|
17
|
+
default_limit: 20
|
|
18
|
+
|
|
19
|
+
# Disables all aggregation functions like count, sum, etc
|
|
20
|
+
# disable_agg_functions: false
|
|
21
|
+
|
|
22
|
+
# Disables all functions like count, length, etc
|
|
23
|
+
# disable_functions: false
|
|
24
|
+
|
|
25
|
+
# Enables using camel case terms in GraphQL which are converted
|
|
26
|
+
# to snake case in SQL
|
|
27
|
+
# enable_camelcase: false
|
|
28
|
+
|
|
29
|
+
# Set session variable "user.id" to the user id
|
|
30
|
+
# Enable this if you need the user id in triggers, etc
|
|
31
|
+
# Note: This will not work with subscriptions
|
|
32
|
+
set_user_id: false
|
|
33
|
+
|
|
34
|
+
# DefaultBlock ensures that in anonymous mode (role 'anon') all tables
|
|
35
|
+
# are blocked from queries and mutations. To open access to tables in
|
|
36
|
+
# anonymous mode they have to be added to the 'anon' role config.
|
|
37
|
+
default_block: false
|
|
38
|
+
|
|
39
|
+
# Define additional variables here to be used with filters
|
|
40
|
+
# Variables used require a type suffix eg. $user_id:bigint
|
|
41
|
+
variables:
|
|
42
|
+
#admin_account_id: "5"
|
|
43
|
+
admin_account_id: "sql:select id from users where admin = true limit 1"
|
|
44
|
+
|
|
45
|
+
# Define variables set to values extracted from http headers
|
|
46
|
+
header_variables:
|
|
47
|
+
remote_ip: "X-Forwarded-For"
|
|
48
|
+
|
|
49
|
+
# Field and table names that you wish to block
|
|
50
|
+
blocklist:
|
|
51
|
+
- ar_internal_metadata
|
|
52
|
+
- schema_migrations
|
|
53
|
+
- secret
|
|
54
|
+
- password
|
|
55
|
+
- encrypted
|
|
56
|
+
- token
|
|
57
|
+
|
|
58
|
+
# resolvers:
|
|
59
|
+
# - name: payments
|
|
60
|
+
# type: remote_api
|
|
61
|
+
# table: customers
|
|
62
|
+
# column: stripe_id
|
|
63
|
+
# json_path: data
|
|
64
|
+
# debug: false
|
|
65
|
+
# url: http://payments/payments/$id
|
|
66
|
+
# pass_headers:
|
|
67
|
+
# - cookie
|
|
68
|
+
# set_headers:
|
|
69
|
+
# - name: Host
|
|
70
|
+
# value: 0.0.0.0
|
|
71
|
+
# # - name: Authorization
|
|
72
|
+
# # value: Bearer <stripe_api_key>
|
|
73
|
+
|
|
74
|
+
tables:
|
|
75
|
+
- # You can create new fields that have a
|
|
76
|
+
# real db table backing them
|
|
77
|
+
name: me
|
|
78
|
+
table: users
|
|
79
|
+
|
|
80
|
+
- name: users
|
|
81
|
+
order_by:
|
|
82
|
+
new_users: ["created_at desc", "id asc"]
|
|
83
|
+
id: ["id asc"]
|
|
84
|
+
|
|
85
|
+
# Variables used require a type suffix eg. $user_id:bigint
|
|
86
|
+
#roles_query: "SELECT * FROM users WHERE id = $user_id:bigint"
|
|
87
|
+
|
|
88
|
+
roles:
|
|
89
|
+
# if `auth.type` is set to a valid auth type then
|
|
90
|
+
# all tables are blocked for the anon role unless
|
|
91
|
+
# added to the role like below.
|
|
92
|
+
# - name: anon
|
|
93
|
+
# tables:
|
|
94
|
+
# - name: users
|
|
95
|
+
# query:
|
|
96
|
+
# limit: 10
|
|
97
|
+
|
|
98
|
+
- name: user
|
|
99
|
+
tables:
|
|
100
|
+
- name: me
|
|
101
|
+
query:
|
|
102
|
+
filters: ["{ id: { _eq: $user_id } }"]
|
|
103
|
+
|
|
104
|
+
# - name: products
|
|
105
|
+
# query:
|
|
106
|
+
# limit: 50
|
|
107
|
+
# filters: ["{ user_id: { eq: $user_id } }"]
|
|
108
|
+
# disable_functions: false
|
|
109
|
+
|
|
110
|
+
# insert:
|
|
111
|
+
# filters: ["{ user_id: { eq: $user_id } }"]
|
|
112
|
+
# presets:
|
|
113
|
+
# - user_id: "$user_id"
|
|
114
|
+
# - created_at: "now"
|
|
115
|
+
|
|
116
|
+
# update:
|
|
117
|
+
# filters: ["{ user_id: { eq: $user_id } }"]
|
|
118
|
+
# presets:
|
|
119
|
+
# - updated_at: "now"
|
|
120
|
+
|
|
121
|
+
# delete:
|
|
122
|
+
# block: true
|
|
123
|
+
|
|
124
|
+
# - name: admin
|
|
125
|
+
# match: id = 1000
|
|
126
|
+
# tables:
|
|
127
|
+
# - name: users
|
|
128
|
+
# filters: []
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Inherit config from this other config file
|
|
2
|
+
# so I only need to overwrite some values
|
|
3
|
+
inherits: dev
|
|
4
|
+
|
|
5
|
+
# When production mode is 'true' only queries
|
|
6
|
+
# from the allow list are permitted.
|
|
7
|
+
production: true
|
|
8
|
+
|
|
9
|
+
# Secret key for general encryption operations like
|
|
10
|
+
# encrypting the cursor data
|
|
11
|
+
secret_key: supercalifajalistics
|
|
12
|
+
|
|
13
|
+
# Subscriptions poll the database to query for updates
|
|
14
|
+
# this sets the duration (in seconds) between requests.
|
|
15
|
+
# Defaults to 5 seconds
|
|
16
|
+
subs_poll_every_seconds: 5
|
|
17
|
+
|
|
18
|
+
# Default limit value to be used on queries and as the max
|
|
19
|
+
# limit on all queries where a limit is defined as a query variable.
|
|
20
|
+
# Defaults to 20
|
|
21
|
+
default_limit: 20
|
package/wasm/graphjin.wasm
CHANGED
|
Binary file
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "./globals.js"
|
|
2
|
+
import * as _ from "./wasm_exec.js";
|
|
3
|
+
|
|
2
4
|
import fs from "fs"
|
|
3
|
-
import * as _ from "./runtime/wasm_exec.js";
|
|
4
5
|
|
|
5
6
|
import { fileURLToPath } from 'url';
|
|
6
7
|
import { dirname, join } from 'path';
|
|
@@ -9,7 +10,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
9
10
|
const __dirname = dirname(__filename);
|
|
10
11
|
|
|
11
12
|
const go = new Go();
|
|
12
|
-
const f = fs.readFileSync(join(__dirname,"
|
|
13
|
+
const f = fs.readFileSync(join(__dirname,"../graphjin.wasm"));
|
|
13
14
|
const inst = await WebAssembly.instantiate(f, go.importObject);
|
|
14
15
|
go.run(inst.instance);
|
|
15
16
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from "fs-extra"
|
|
2
|
+
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { basename, dirname, join } from 'path';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
const src = join(__dirname,"../config")
|
|
10
|
+
const dst = process.env.INIT_CWD
|
|
11
|
+
|
|
12
|
+
const newDst = join(dst, basename(src));
|
|
13
|
+
|
|
14
|
+
const opt = {
|
|
15
|
+
overwrite: false,
|
|
16
|
+
errorOnExist: false,
|
|
17
|
+
dereference: true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
await fs.emptyDir(newDst)
|
|
22
|
+
await fs.copy(src, newDst, opt)
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error(err)
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
File without changes
|