Skip to content

Commit 974c772

Browse files
committed
update graphql function for for 0.5
1 parent 7824422 commit 974c772

File tree

12 files changed

+79
-84
lines changed

12 files changed

+79
-84
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Kevin Old ([Twitter](https://twitter.com/kevinold))
2020

2121
## Install & Deploy
2222

23-
Make sure you have the most recent version of the [Serverless Framework](http://www.serverless.com) (0.3.x and higher) and you are using NodeV4 or greater.
23+
Make sure you have the most recent version of the [Serverless Framework](http://www.serverless.com) (0.5.x and higher) and you are using NodeV4 or greater.
2424

2525
```
2626
npm install serverless -g
@@ -63,7 +63,7 @@ Usage with [GraphiQL.app][3] (an Electron wrapper around [GraphiQL][2]) is recom
6363

6464
#### List of author names
6565
```
66-
curl -XPOST -d '{"query": "{ authors { name } }"}' <endpoint>/dev/resource/graphql
66+
curl -XPOST -d '{"query": "{ authors { name } }"}' <endpoint>/dev/blog/graphql
6767
```
6868

6969
#### Results
@@ -79,7 +79,7 @@ curl -XPOST -d '{"query": "{ authors { name } }"}' <endpoint>/dev/resource/graph
7979

8080
### List of posts with id and title
8181
```
82-
curl -XPOST -d '{"query": "{ posts { id, title } }"}' <endpoint>/dev/resource/graphql
82+
curl -XPOST -d '{"query": "{ posts { id, title } }"}' <endpoint>/dev/blog/graphql
8383
```
8484

8585
#### Results
@@ -97,7 +97,7 @@ curl -XPOST -d '{"query": "{ posts { id, title } }"}' <endpoint>/dev/resource/gr
9797

9898
#### List of posts with id, title and *nested* author name
9999
```
100-
curl -XPOST -d '{"query": "{ posts { id, title, author { name } } }"}' <endpoint>/dev/resource/graphql
100+
curl -XPOST -d '{"query": "{ posts { id, title, author { name } } }"}' <endpoint>/dev/blog/graphql
101101
```
102102

103103
#### Results
@@ -118,7 +118,7 @@ curl -XPOST -d '{"query": "{ posts { id, title, author { name } } }"}' <endpoint
118118

119119
#### List of posts with post, author and comments information (for a Post with no comments, i.e. comments:[])
120120
```
121-
curl -XPOST -d '{"query": "{ posts { id, title, author { id, name }, comments { id, content, author { name } } } }"}' <endpoint>/dev/resource/graphql
121+
curl -XPOST -d '{"query": "{ posts { id, title, author { id, name }, comments { id, content, author { name } } } }"}' <endpoint>/dev/blog/graphql
122122
```
123123

124124
#### Results
@@ -145,7 +145,7 @@ curl -XPOST -d '{"query": "{ posts { id, title, author { id, name }, comments {
145145

146146
#### Create Post
147147
```
148-
curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"5\", title: \"Fifth post!\", bodyContent: \"Test content\", author: \"1\") { id, title } }"}' <endpoint>/dev/resource/graphql
148+
curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"5\", title: \"Fifth post!\", bodyContent: \"Test content\", author: \"1\") { id, title } }"}' <endpoint>/dev/blog/graphql
149149
```
150150

151151
#### Results
@@ -165,7 +165,7 @@ curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"5\",
165165

166166
Validations defined using [graphql-custom-types][4] in [blog/lib/schema.js][5]
167167
```
168-
curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"8\", title: \"123456789\", bodyContent: \"Test content 5\") { id, title } }"}' <endpoint>/dev/resource/graphql
168+
curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"8\", title: \"123456789\", bodyContent: \"Test content 5\") { id, title } }"}' <endpoint>/dev/blog/graphql
169169
```
170170

171171
#### Results
@@ -181,7 +181,7 @@ curl -XPOST -d '{"query": "mutation createNewPost { post: createPost (id: \"8\",
181181

182182
### Introspection Query
183183
```
184-
curl -XPOST -d '{"query": "{__schema { queryType { name, fields { name, description} }}}"}' <endpoint>/dev/resource/graphql
184+
curl -XPOST -d '{"query": "{__schema { queryType { name, fields { name, description} }}}"}' <endpoint>/dev/blog/graphql
185185
```
186186

187187
Returns:
File renamed without changes.

blog/resource/graphql/handler.js renamed to blog/graphql/handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
var ServerlessHelpers = require('serverless-helpers-js').loadEnv();
1212

1313
// Require Logic
14-
var lib = require('../../lib');
14+
var lib = require('../lib');
1515

1616
// Lambda Handler
1717
module.exports.handler = function(event, context) {

blog/graphql/s-function.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "graphql",
3+
"runtime": "nodejs4.3",
4+
"description": "Serverless Lambda function for project: serverless-graphql-blog",
5+
"customName": false,
6+
"customRole": false,
7+
"handler": "graphql/handler.handler",
8+
"timeout": 6,
9+
"memorySize": 1024,
10+
"authorizer": {},
11+
"custom": {
12+
"excludePatterns": [],
13+
"optimize": {
14+
"exclude": [
15+
"aws-sdk"
16+
],
17+
"transforms": [
18+
{
19+
"name": "babelify",
20+
"opts": {
21+
"presets": [
22+
"es2015"
23+
]
24+
}
25+
}
26+
]
27+
}
28+
},
29+
"endpoints": [
30+
{
31+
"path": "blog/graphql",
32+
"method": "POST",
33+
"type": "AWS",
34+
"authorizationType": "none",
35+
"authorizerFunction": false,
36+
"apiKeyRequired": false,
37+
"requestParameters": {},
38+
"requestTemplates": {
39+
"application/json": "{\"query\" : $input.json(\"$\")}"
40+
},
41+
"responses": {
42+
"400": {
43+
"statusCode": "400"
44+
},
45+
"default": {
46+
"statusCode": "200",
47+
"responseParameters": {},
48+
"responseModels": {},
49+
"responseTemplates": {},
50+
"application/json": ""
51+
}
52+
}
53+
}
54+
],
55+
"events": [],
56+
"environment": {
57+
"SERVERLESS_PROJECT": "${project}",
58+
"SERVERLESS_STAGE": "${stage}",
59+
"SERVERLESS_REGION": "${region}"
60+
},
61+
"vpc": {
62+
"securityGroupIds": [],
63+
"subnetIds": []
64+
}
65+
}
File renamed without changes.

blog/lib/dynamo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const dynamoConfig = {
66
};
77
const docClient = new AWS.DynamoDB.DocumentClient(dynamoConfig);
88
const stage = process.env.SERVERLESS_STAGE;
9-
const projectName = process.env.SERVERLESS_PROJECT_NAME;
9+
const projectName = process.env.SERVERLESS_PROJECT;
1010
const postsTable = projectName + '-posts-' + stage;
1111
const authorsTable = projectName + '-authors-' + stage;
1212
const commentsTable = projectName + '-comments-' + stage;

blog/resource/graphql/s-function.json

Lines changed: 0 additions & 35 deletions
This file was deleted.

blog/resource/s-module.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

blog/s-component.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"dependencies": {
1313
"babelify": "^7.2.0",
1414
"babel-preset-es2015": "^6.3.13",
15-
"serverless-optimizer-plugin": "^1.0.0"
15+
"serverless-optimizer-plugin": "^2.5.1"
1616
}
17-
}
17+
}

0 commit comments

Comments
 (0)