Skip to content

Commit 45452e5

Browse files
author
awstools
committed
feat(client-appsync): This release introduces the APPSYNC_JS runtime, and adds support for JavaScript in AppSync functions and AppSync pipeline resolvers.
1 parent db91280 commit 45452e5

File tree

13 files changed

+1908
-919
lines changed

13 files changed

+1908
-919
lines changed

clients/client-appsync/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
AWS SDK for JavaScript AppSync Client for Node.js, Browser and React Native.
1111

12-
<p>AppSync provides API actions for creating and interacting with data
13-
sources using GraphQL from your application.</p>
12+
<p>AppSync provides API actions for creating and interacting with data sources using GraphQL
13+
from your application.</p>
1414

1515
## Installing
1616

clients/client-appsync/src/AppSync.ts

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ import {
8484
DisassociateApiCommandInput,
8585
DisassociateApiCommandOutput,
8686
} from "./commands/DisassociateApiCommand";
87+
import {
88+
EvaluateCodeCommand,
89+
EvaluateCodeCommandInput,
90+
EvaluateCodeCommandOutput,
91+
} from "./commands/EvaluateCodeCommand";
8792
import {
8893
EvaluateMappingTemplateCommand,
8994
EvaluateMappingTemplateCommandInput,
@@ -214,8 +219,8 @@ import {
214219
import { UpdateTypeCommand, UpdateTypeCommandInput, UpdateTypeCommandOutput } from "./commands/UpdateTypeCommand";
215220

216221
/**
217-
* <p>AppSync provides API actions for creating and interacting with data
218-
* sources using GraphQL from your application.</p>
222+
* <p>AppSync provides API actions for creating and interacting with data sources using GraphQL
223+
* from your application.</p>
219224
*/
220225
export class AppSync extends AppSyncClient {
221226
/**
@@ -374,8 +379,7 @@ export class AppSync extends AppSyncClient {
374379

375380
/**
376381
* <p>Creates a <code>Function</code> object.</p>
377-
* <p>A function is a reusable entity. You can use multiple functions to compose the resolver
378-
* logic.</p>
382+
* <p>A function is a reusable entity. You can use multiple functions to compose the resolver logic.</p>
379383
*/
380384
public createFunction(
381385
args: CreateFunctionCommandInput,
@@ -440,8 +444,8 @@ export class AppSync extends AppSyncClient {
440444

441445
/**
442446
* <p>Creates a <code>Resolver</code> object.</p>
443-
* <p>A resolver converts incoming requests into a format that a data source can understand,
444-
* and converts the data source's responses into GraphQL.</p>
447+
* <p>A resolver converts incoming requests into a format that a data source can understand, and converts the data
448+
* source's responses into GraphQL.</p>
445449
*/
446450
public createResolver(
447451
args: CreateResolverCommandInput,
@@ -778,12 +782,44 @@ export class AppSync extends AppSyncClient {
778782
}
779783

780784
/**
781-
* <p>Evaluates a given template and returns the response. The mapping template can be a
782-
* request or response template.</p>
783-
* <p>Request templates take the incoming request after a GraphQL operation is parsed and
784-
* convert it into a request configuration for the selected data source operation. Response
785-
* templates interpret responses from the data source and map it to the shape of the GraphQL
786-
* field output type.</p>
785+
* <p>Evaluates the given code and returns the response. The code definition requirements depend on the specified
786+
* runtime. For <code>APPSYNC_JS</code> runtimes, the code defines the request and response functions. The request
787+
* function takes the incoming request after a GraphQL operation is parsed and converts it into a request
788+
* configuration for the selected data source operation. The response function interprets responses from the data
789+
* source and maps it to the shape of the GraphQL field output type. </p>
790+
*/
791+
public evaluateCode(
792+
args: EvaluateCodeCommandInput,
793+
options?: __HttpHandlerOptions
794+
): Promise<EvaluateCodeCommandOutput>;
795+
public evaluateCode(args: EvaluateCodeCommandInput, cb: (err: any, data?: EvaluateCodeCommandOutput) => void): void;
796+
public evaluateCode(
797+
args: EvaluateCodeCommandInput,
798+
options: __HttpHandlerOptions,
799+
cb: (err: any, data?: EvaluateCodeCommandOutput) => void
800+
): void;
801+
public evaluateCode(
802+
args: EvaluateCodeCommandInput,
803+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: EvaluateCodeCommandOutput) => void),
804+
cb?: (err: any, data?: EvaluateCodeCommandOutput) => void
805+
): Promise<EvaluateCodeCommandOutput> | void {
806+
const command = new EvaluateCodeCommand(args);
807+
if (typeof optionsOrCb === "function") {
808+
this.send(command, optionsOrCb);
809+
} else if (typeof cb === "function") {
810+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
811+
this.send(command, optionsOrCb || {}, cb);
812+
} else {
813+
return this.send(command, optionsOrCb);
814+
}
815+
}
816+
817+
/**
818+
* <p>Evaluates a given template and returns the response. The mapping template can be a request or response
819+
* template.</p>
820+
* <p>Request templates take the incoming request after a GraphQL operation is parsed and convert it into a
821+
* request configuration for the selected data source operation. Response templates interpret responses from the
822+
* data source and map it to the shape of the GraphQL field output type.</p>
787823
* <p>Mapping templates are written in the Apache Velocity Template Language (VTL).</p>
788824
*/
789825
public evaluateMappingTemplate(
@@ -1146,10 +1182,9 @@ export class AppSync extends AppSyncClient {
11461182
/**
11471183
* <p>Lists the API keys for a given API.</p>
11481184
* <note>
1149-
* <p>API keys are deleted automatically 60 days after they expire. However, they may still
1150-
* be included in the response until they have actually been deleted. You can safely call
1151-
* <code>DeleteApiKey</code> to manually delete a key before it's automatically
1152-
* deleted.</p>
1185+
* <p>API keys are deleted automatically 60 days after they expire. However, they may still be included in the
1186+
* response until they have actually been deleted. You can safely call <code>DeleteApiKey</code> to manually
1187+
* delete a key before it's automatically deleted.</p>
11531188
* </note>
11541189
*/
11551190
public listApiKeys(args: ListApiKeysCommandInput, options?: __HttpHandlerOptions): Promise<ListApiKeysCommandOutput>;
@@ -1427,8 +1462,8 @@ export class AppSync extends AppSyncClient {
14271462

14281463
/**
14291464
* <p>Adds a new schema to your GraphQL API.</p>
1430-
* <p>This operation is asynchronous. Use to
1431-
* determine when it has completed.</p>
1465+
* <p>This operation is asynchronous. Use to determine when it has
1466+
* completed.</p>
14321467
*/
14331468
public startSchemaCreation(
14341469
args: StartSchemaCreationCommandInput,

clients/client-appsync/src/AppSyncClient.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { DeleteGraphqlApiCommandInput, DeleteGraphqlApiCommandOutput } from "./c
6565
import { DeleteResolverCommandInput, DeleteResolverCommandOutput } from "./commands/DeleteResolverCommand";
6666
import { DeleteTypeCommandInput, DeleteTypeCommandOutput } from "./commands/DeleteTypeCommand";
6767
import { DisassociateApiCommandInput, DisassociateApiCommandOutput } from "./commands/DisassociateApiCommand";
68+
import { EvaluateCodeCommandInput, EvaluateCodeCommandOutput } from "./commands/EvaluateCodeCommand";
6869
import {
6970
EvaluateMappingTemplateCommandInput,
7071
EvaluateMappingTemplateCommandOutput,
@@ -142,6 +143,7 @@ export type ServiceInputTypes =
142143
| DeleteResolverCommandInput
143144
| DeleteTypeCommandInput
144145
| DisassociateApiCommandInput
146+
| EvaluateCodeCommandInput
145147
| EvaluateMappingTemplateCommandInput
146148
| FlushApiCacheCommandInput
147149
| GetApiAssociationCommandInput
@@ -194,6 +196,7 @@ export type ServiceOutputTypes =
194196
| DeleteResolverCommandOutput
195197
| DeleteTypeCommandOutput
196198
| DisassociateApiCommandOutput
199+
| EvaluateCodeCommandOutput
197200
| EvaluateMappingTemplateCommandOutput
198201
| FlushApiCacheCommandOutput
199202
| GetApiAssociationCommandOutput
@@ -377,8 +380,8 @@ type AppSyncClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandl
377380
export interface AppSyncClientResolvedConfig extends AppSyncClientResolvedConfigType {}
378381

379382
/**
380-
* <p>AppSync provides API actions for creating and interacting with data
381-
* sources using GraphQL from your application.</p>
383+
* <p>AppSync provides API actions for creating and interacting with data sources using GraphQL
384+
* from your application.</p>
382385
*/
383386
export class AppSyncClient extends __Client<
384387
__HttpHandlerOptions,

clients/client-appsync/src/commands/CreateFunctionCommand.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export interface CreateFunctionCommandOutput extends CreateFunctionResponse, __M
3030

3131
/**
3232
* <p>Creates a <code>Function</code> object.</p>
33-
* <p>A function is a reusable entity. You can use multiple functions to compose the resolver
34-
* logic.</p>
33+
* <p>A function is a reusable entity. You can use multiple functions to compose the resolver logic.</p>
3534
* @example
3635
* Use a bare-bones client and the command you need to make an API call.
3736
* ```javascript

clients/client-appsync/src/commands/CreateResolverCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export interface CreateResolverCommandOutput extends CreateResolverResponse, __M
3030

3131
/**
3232
* <p>Creates a <code>Resolver</code> object.</p>
33-
* <p>A resolver converts incoming requests into a format that a data source can understand,
34-
* and converts the data source's responses into GraphQL.</p>
33+
* <p>A resolver converts incoming requests into a format that a data source can understand, and converts the data
34+
* source's responses into GraphQL.</p>
3535
* @example
3636
* Use a bare-bones client and the command you need to make an API call.
3737
* ```javascript
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// smithy-typescript generated code
2+
import { EndpointParameterInstructions, getEndpointPlugin } from "@aws-sdk/middleware-endpoint";
3+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
4+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
5+
import { Command as $Command } from "@aws-sdk/smithy-client";
6+
import {
7+
FinalizeHandlerArguments,
8+
Handler,
9+
HandlerExecutionContext,
10+
HttpHandlerOptions as __HttpHandlerOptions,
11+
MetadataBearer as __MetadataBearer,
12+
MiddlewareStack,
13+
SerdeContext as __SerdeContext,
14+
} from "@aws-sdk/types";
15+
16+
import { AppSyncClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../AppSyncClient";
17+
import {
18+
EvaluateCodeRequest,
19+
EvaluateCodeRequestFilterSensitiveLog,
20+
EvaluateCodeResponse,
21+
EvaluateCodeResponseFilterSensitiveLog,
22+
} from "../models/models_0";
23+
import {
24+
deserializeAws_restJson1EvaluateCodeCommand,
25+
serializeAws_restJson1EvaluateCodeCommand,
26+
} from "../protocols/Aws_restJson1";
27+
28+
export interface EvaluateCodeCommandInput extends EvaluateCodeRequest {}
29+
export interface EvaluateCodeCommandOutput extends EvaluateCodeResponse, __MetadataBearer {}
30+
31+
/**
32+
* <p>Evaluates the given code and returns the response. The code definition requirements depend on the specified
33+
* runtime. For <code>APPSYNC_JS</code> runtimes, the code defines the request and response functions. The request
34+
* function takes the incoming request after a GraphQL operation is parsed and converts it into a request
35+
* configuration for the selected data source operation. The response function interprets responses from the data
36+
* source and maps it to the shape of the GraphQL field output type. </p>
37+
* @example
38+
* Use a bare-bones client and the command you need to make an API call.
39+
* ```javascript
40+
* import { AppSyncClient, EvaluateCodeCommand } from "@aws-sdk/client-appsync"; // ES Modules import
41+
* // const { AppSyncClient, EvaluateCodeCommand } = require("@aws-sdk/client-appsync"); // CommonJS import
42+
* const client = new AppSyncClient(config);
43+
* const command = new EvaluateCodeCommand(input);
44+
* const response = await client.send(command);
45+
* ```
46+
*
47+
* @see {@link EvaluateCodeCommandInput} for command's `input` shape.
48+
* @see {@link EvaluateCodeCommandOutput} for command's `response` shape.
49+
* @see {@link AppSyncClientResolvedConfig | config} for AppSyncClient's `config` shape.
50+
*
51+
*/
52+
export class EvaluateCodeCommand extends $Command<
53+
EvaluateCodeCommandInput,
54+
EvaluateCodeCommandOutput,
55+
AppSyncClientResolvedConfig
56+
> {
57+
// Start section: command_properties
58+
// End section: command_properties
59+
60+
public static getEndpointParameterInstructions(): EndpointParameterInstructions {
61+
return {
62+
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
63+
Endpoint: { type: "builtInParams", name: "endpoint" },
64+
Region: { type: "builtInParams", name: "region" },
65+
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
66+
};
67+
}
68+
69+
constructor(readonly input: EvaluateCodeCommandInput) {
70+
// Start section: command_constructor
71+
super();
72+
// End section: command_constructor
73+
}
74+
75+
/**
76+
* @internal
77+
*/
78+
resolveMiddleware(
79+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
80+
configuration: AppSyncClientResolvedConfig,
81+
options?: __HttpHandlerOptions
82+
): Handler<EvaluateCodeCommandInput, EvaluateCodeCommandOutput> {
83+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
84+
this.middlewareStack.use(getEndpointPlugin(configuration, EvaluateCodeCommand.getEndpointParameterInstructions()));
85+
86+
const stack = clientStack.concat(this.middlewareStack);
87+
88+
const { logger } = configuration;
89+
const clientName = "AppSyncClient";
90+
const commandName = "EvaluateCodeCommand";
91+
const handlerExecutionContext: HandlerExecutionContext = {
92+
logger,
93+
clientName,
94+
commandName,
95+
inputFilterSensitiveLog: EvaluateCodeRequestFilterSensitiveLog,
96+
outputFilterSensitiveLog: EvaluateCodeResponseFilterSensitiveLog,
97+
};
98+
const { requestHandler } = configuration;
99+
return stack.resolve(
100+
(request: FinalizeHandlerArguments<any>) =>
101+
requestHandler.handle(request.request as __HttpRequest, options || {}),
102+
handlerExecutionContext
103+
);
104+
}
105+
106+
private serialize(input: EvaluateCodeCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
107+
return serializeAws_restJson1EvaluateCodeCommand(input, context);
108+
}
109+
110+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<EvaluateCodeCommandOutput> {
111+
return deserializeAws_restJson1EvaluateCodeCommand(output, context);
112+
}
113+
114+
// Start section: command_body_extra
115+
// End section: command_body_extra
116+
}

clients/client-appsync/src/commands/EvaluateMappingTemplateCommand.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ export interface EvaluateMappingTemplateCommandInput extends EvaluateMappingTemp
2929
export interface EvaluateMappingTemplateCommandOutput extends EvaluateMappingTemplateResponse, __MetadataBearer {}
3030

3131
/**
32-
* <p>Evaluates a given template and returns the response. The mapping template can be a
33-
* request or response template.</p>
34-
* <p>Request templates take the incoming request after a GraphQL operation is parsed and
35-
* convert it into a request configuration for the selected data source operation. Response
36-
* templates interpret responses from the data source and map it to the shape of the GraphQL
37-
* field output type.</p>
32+
* <p>Evaluates a given template and returns the response. The mapping template can be a request or response
33+
* template.</p>
34+
* <p>Request templates take the incoming request after a GraphQL operation is parsed and convert it into a
35+
* request configuration for the selected data source operation. Response templates interpret responses from the
36+
* data source and map it to the shape of the GraphQL field output type.</p>
3837
* <p>Mapping templates are written in the Apache Velocity Template Language (VTL).</p>
3938
* @example
4039
* Use a bare-bones client and the command you need to make an API call.

clients/client-appsync/src/commands/ListApiKeysCommand.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ export interface ListApiKeysCommandOutput extends ListApiKeysResponse, __Metadat
3131
/**
3232
* <p>Lists the API keys for a given API.</p>
3333
* <note>
34-
* <p>API keys are deleted automatically 60 days after they expire. However, they may still
35-
* be included in the response until they have actually been deleted. You can safely call
36-
* <code>DeleteApiKey</code> to manually delete a key before it's automatically
37-
* deleted.</p>
34+
* <p>API keys are deleted automatically 60 days after they expire. However, they may still be included in the
35+
* response until they have actually been deleted. You can safely call <code>DeleteApiKey</code> to manually
36+
* delete a key before it's automatically deleted.</p>
3837
* </note>
3938
* @example
4039
* Use a bare-bones client and the command you need to make an API call.

clients/client-appsync/src/commands/StartSchemaCreationCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export interface StartSchemaCreationCommandOutput extends StartSchemaCreationRes
3030

3131
/**
3232
* <p>Adds a new schema to your GraphQL API.</p>
33-
* <p>This operation is asynchronous. Use to
34-
* determine when it has completed.</p>
33+
* <p>This operation is asynchronous. Use to determine when it has
34+
* completed.</p>
3535
* @example
3636
* Use a bare-bones client and the command you need to make an API call.
3737
* ```javascript

clients/client-appsync/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export * from "./DeleteGraphqlApiCommand";
1717
export * from "./DeleteResolverCommand";
1818
export * from "./DeleteTypeCommand";
1919
export * from "./DisassociateApiCommand";
20+
export * from "./EvaluateCodeCommand";
2021
export * from "./EvaluateMappingTemplateCommand";
2122
export * from "./FlushApiCacheCommand";
2223
export * from "./GetApiAssociationCommand";

0 commit comments

Comments
 (0)