You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/general-config.md
-6Lines changed: 0 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,12 +48,6 @@ appSync:
48
48
- `caching`: See [Cacing](caching.md)
49
49
- `waf`: See [Web Application Firefall](WAF.md)
50
50
- `logging`: See [Logging](#Logging)
51
-
- `defaultMappingTemplates`:
52
-
- `request`: Optional. A default request mapping template filename for all resolvers.
53
-
- `response`: Optional. A default response mapping template filename for all resolvers.
54
-
- `mappingTemplatesLocation`:
55
-
- `resolvers`: The location where to find resolver mapping templates, relative to the service path. Defaults to `mapping-templates`.
56
-
- `pipelineFunctions`: The location where to find pipeline functions mapping templates. Defaults to the same value as `mappingTemplatesLocation.resolvers`.
57
51
- `xrayEnabled`: Boolean. Enable or disable X-Ray tracing.
58
52
- `tags`: A key-value pair for tagging this AppSync API
Copy file name to clipboardExpand all lines: doc/pipeline-functions.md
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,28 +4,33 @@ When you use `PIPELINE` [resolvers](resolvers.md), you will also need to define
4
4
5
5
It's a key-value pair object whose key is the name of the function and the value is its configuration.
6
6
7
-
The definition can also be a string in which case it's the [dataSource](dataSources.md) name to use. The other attributes use the default values.
8
-
9
7
## Quick start
10
8
11
9
```yaml
12
10
appSync:
13
11
pipelineFunctions:
14
-
myFunction:myDataSource
15
-
myOtherFunction:
16
-
dataSource: myOtherDataSource
12
+
myFunction:
13
+
dataSource: myDataSource
14
+
code: myFunction.js
17
15
```
18
16
19
17
## Configutation
20
18
21
19
- `dataSource`: The name of the dataSource to use.
22
20
- `description`: An optional description for this pipeline function.
23
-
- `request`: The request mapping template file name to use for this resolver, or `false` for [direct lambda](https://docs.aws.amazon.com/appsync/latest/devguide/direct-lambda-reference.html). Defaults to `{functionName}.request.vtl`.
24
-
- `response`: The request mapping template file name to use for this resolver, or `false` for [direct lambda](https://docs.aws.amazon.com/appsync/latest/devguide/direct-lambda-reference.html). Defaults to `{functionName}.response.vtl`.
21
+
- `code`: The path to the JS resolver handler file, relative to `serverless.yml`.
22
+
- `request`: The path to the VTL request mapping template file, relative to `serverless.yml`.
23
+
- `response`: The path to the VTL response mapping template file, relative to `serverless.yml`.
25
24
- `maxBatchSize`: The maximum [batch size](https://aws.amazon.com/blogs/mobile/introducing-configurable-batching-size-for-aws-appsync-lambda-resolvers/) to use (only available for AWS Lambda DataAources)
26
25
- `substitutions`: See [VTL template substitutions](substitutions.md)
27
26
- `sync`: [See SyncConfig](syncConfig.md)
28
27
28
+
## JavaScript vs VTL vs Direct Lambda
29
+
30
+
When `code` is specified, the JavaScript runtime is used. When `request` and/or `response` are specified, the VTL runtime is used.
31
+
32
+
To use [direct lambda](https://docs.aws.amazon.com/appsync/latest/devguide/direct-lambda-reference.html), don't specify anything (only works with Lambda function data sources).
33
+
29
34
## Inline DataSources
30
35
31
36
Just like with `UNIT` resolvers, you can [define the dataSource inline](resolvers.md#inline-datasources) in pipeline functions.
Copy file name to clipboardExpand all lines: doc/resolvers.md
+35-7Lines changed: 35 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,6 @@ All the Resolvers in your AppSync API can be found in serverless.yml under the `
4
4
5
5
Resolvers are defined using key-value pairs where the key can either be an arbitrary name for the resolver or the `type` and `field` in the schema it is attached to separated with a dot (`.`), and the value is the configuration of the resolver.
6
6
7
-
The definition can also be a string in which case it's the [dataSource](dataSources.md) name to use. The other attributes use the default values.
8
-
9
7
## Quick start
10
8
11
9
```yaml
@@ -14,8 +12,6 @@ appSync:
14
12
Query.user:
15
13
dataSource: myDataSource
16
14
17
-
Query.users: myDataSource
18
-
19
15
getPosts:
20
16
type: Query
21
17
field: getPosts
@@ -26,15 +22,34 @@ appSync:
26
22
27
23
- `type`: The Type in the schema this resolver is attached to. Optional if specified in the configuration key.
28
24
- `field`: The Field in the schema this resolver is attached to. Optional if specified in the configuration key.
29
-
- `kind`: The kind of resolver. Can be `UNIT` or `PIPELINE` ([see below](#PIPELINE-resolvers)). Defaults to `UNIT`
25
+
- `kind`: The kind of resolver. Can be `UNIT` or `PIPELINE` ([see below](#PIPELINE-resolvers)). Defaults to `PIPELINE`
30
26
- `dataSource`: The name of the [dataSource](dataSources.md) this resolver uses.
31
27
- `maxBatchSize`: The maximum [batch size](https://aws.amazon.com/blogs/mobile/introducing-configurable-batching-size-for-aws-appsync-lambda-resolvers/) to use (only available for AWS Lambda DataSources)
32
-
- `request`: The request mapping template file name to use for this resolver, or `false` for [direct lambda](https://docs.aws.amazon.com/appsync/latest/devguide/direct-lambda-reference.html). Defaults to `{type}.{field}.request.vtl`.
33
-
- `response`: The request mapping template file name to use for this resolver, or `false` for [direct lambda](https://docs.aws.amazon.com/appsync/latest/devguide/direct-lambda-reference.html). Defaults to `{type}.{field}.response.vtl`.
28
+
- `code`: The path of the JavaScript resolver handler file, relative to `serverless.yml`. If not specified, a [minimalistic default](#javascript-vs-vtl) is used.
29
+
- `request`: The path to the VTL request mapping template file, relative to `serverless.yml`.
30
+
- `response`: The path to the VTL response mapping template file, relative to `serverless.yml`.
34
31
- `substitutions`: See [VTL template substitutions](substitutions.md)
35
32
- `caching`: [See below](#Caching)
36
33
- `sync`: [See SyncConfig](syncConfig.md)
37
34
35
+
## JavaScript vs VTL
36
+
37
+
When `code` is specified, the JavaScript runtime is used. When `request` and/or `response` are specified, the VTL runtime is used.
38
+
39
+
If neither are specified, by default, the resolver is a PIPELINE JavaScript resolver, and the following minimalistic resolver handler is used.
40
+
41
+
```js
42
+
export function request() {
43
+
return {};
44
+
}
45
+
46
+
export function response(ctx) {
47
+
return ctx.prev.result;
48
+
}
49
+
```
50
+
51
+
To use [direct lambda](https://docs.aws.amazon.com/appsync/latest/devguide/direct-lambda-reference.html), set `kind` to `UNIT` and don't specify `request` and `response` (only works with Lambda function data sources).
52
+
38
53
## PIPELINE resolvers
39
54
40
55
When `kind` is `PIPELINE`, you can specify the [pipeline function](pipeline-functions.md) names to use:
@@ -73,6 +88,19 @@ appSync:
73
88
handler: 'functions/getUser.handler'
74
89
```
75
90
91
+
## Inline function definitions
92
+
93
+
If a [Pipeline function](pipeline-functions.md) is only used in a single resolver, you can also define it inline in the resolver configuration.
Copy file name to clipboardExpand all lines: doc/upgrading-from-v1.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,33 @@ custom:
35
35
36
36
Place your APIs into defferent stacks. Unfortunately, this WILL require **the replacement of the APIs**. You can probably use [custom domains](custom-domain.md) to workaround that, if that's an option.
37
37
38
+
### Defaults to PIPELINE and JavaScript resolvers
39
+
40
+
The new default runtime is JavaScript.
41
+
42
+
The new default `KIND` for resolvers is `PIPELINE`. For several reasons:
43
+
44
+
- The JavaScript runtime, is only supportsed with PIPELINE resolvers
45
+
- It makes migrations easier later, if you need to add functions to your resolvers.
46
+
47
+
> 💡 To simulate a UNIT resolver, use a PIPELINE with only one function.
48
+
49
+
```yml
50
+
resolvers:
51
+
Query.getPost:
52
+
functions:
53
+
- dataSource: posts
54
+
code: resolvers/getPost.js
55
+
```
56
+
57
+
### No more defaults for resolver handler paths.
58
+
59
+
In `v1`, if you did not specify a path to your mapping templates, a default based on the type, field or function name was used. (e.g. `Query.getPost.request.vtl`).
60
+
61
+
To avoid unexpected behaviours, you are now required to explicitely specify the path to your resolver handlers. i.e. use `code` for Pipeline JS resolvers or `request`/`response` for VTL.
62
+
63
+
There is also no more `mappingTemplatesLocation` option. Paths must be relative to the `serverless.yml`. This aligns more with how Serverless Framework handles Lambda function handlers' paths.
64
+
38
65
### Graphiql "playground"
39
66
40
67
The `graphql-playground` command which started a graphiql server pointing to the AppSync API has been removed.
0 commit comments