Skip to content

Commit 48750de

Browse files
committed
Add proof of concept
1 parent 930bb38 commit 48750de

File tree

9 files changed

+2932
-0
lines changed

9 files changed

+2932
-0
lines changed

.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
"stage-0",
4+
"latest"
5+
],
6+
"plugins": [
7+
"transform-runtime"
8+
]
9+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
node_modules

Readme.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# lambda-graphql-apex
2+
3+
Install [Apex](http://apex.run) and configure your [AWS Credentials](http://apex.run/#aws-credentials) then follow the instructions below.
4+
5+
Install NPM dependencies:
6+
7+
```
8+
$ npm install
9+
```
10+
11+
Initialize the function role:
12+
```
13+
$ apex init
14+
```
15+
16+
*This creates a folder at `./functions/hello`. You should delete it.*
17+
18+
Add extra options from `project.json_stub` to generated `project.json` to include the runtime, handler and hook options.
19+
20+
Deploy the functions:
21+
22+
```
23+
$ apex deploy
24+
```
25+
26+
Try it out:
27+
28+
```
29+
$ apex invoke graphql-example < event.json
30+
```
31+
32+
AWS Resources that will be created:
33+
- IAM role
34+
- IAM policy
35+
- Lambda function

event.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"query": "{ hello }"
3+
}

functions/graphql-example/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { graphql, buildSchema } from 'graphql';
2+
import λ from 'apex.js';
3+
4+
export default λ(e => {
5+
let schema = buildSchema(`
6+
type Query {
7+
hello: String
8+
}
9+
`);
10+
11+
let root = {
12+
hello: () => 'Hello World!'
13+
};
14+
15+
return graphql(schema, e.query, root);
16+
});

0 commit comments

Comments
 (0)