Skip to content

Commit d043143

Browse files
committed
doc: add basic readme
1 parent ae018bc commit d043143

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
11
# express-graphql-proxy
2-
a proxy server built on top of express.js for graphql services.
2+
3+
A graphql proxy server implemented on top of express for adding custom RBAC to existing graphql endpoints.
4+
5+
```js
6+
import createApp from '@antstackio/express-graphql-proxy'
7+
8+
const requestParams = {
9+
resourceUri: "https://graphql-pokemon2.vercel.app",
10+
headers
11+
};
12+
13+
const app = createApp(
14+
requestParams,
15+
handlerFunc
16+
);
17+
18+
const handlers = {
19+
query: {
20+
pokemons
21+
}
22+
};
23+
24+
function pokemons(variables, selectionFields, {req, res}) {
25+
if(parseInt(variables.id) > 150) {
26+
return res.status(400).send("cant query pokemons > 150 in this league");
27+
}
28+
return true;
29+
}
30+
31+
function HandlerFunc() {
32+
33+
const result = gqlObject.queryObjects.every((item) =>
34+
// map the gqlObject to a suitable handler
35+
handlers[gqlObject.type][item.operationName](
36+
item.variables,
37+
item.selectedFields,
38+
context
39+
)
40+
);
41+
return result;
42+
}
43+
```
44+
45+
## Installation
46+
47+
This is a `node.js` module available through npm registry. Installation can be done using npm or yarn.
48+
49+
```bash
50+
$ npm install @antstackio/express-graphql-proxy
51+
52+
$ yarn add @antstackio/express-graphql-proxy
53+
```
54+
55+
## Philosophy
56+
57+
There are services that provide graphql endpoints over http leaving the developer to come up with their own mechanism for authorisation and controllings permission for the access of resources. This library help in bootstrapping a middleware proxy server that makes it easy to implement RBAC without loosing the fun in using graphql from the client.
58+
59+
## Documentation
60+
61+
TODO
62+
63+
## Examples
64+
65+
check out the example folder for quick start.

0 commit comments

Comments
 (0)