@ttoss/appsync-api 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/dist/cli.js +0 -3688
- package/dist/esm/chunk-5MBGDEAO.js +750 -0
- package/dist/esm/chunk-NQOARNEJ.js +27 -0
- package/dist/esm/cli.js +2 -2
- package/dist/esm/index.js +5 -4
- package/dist/esm/server.js +43 -0
- package/dist/index.d.ts +15 -5
- package/dist/index.js +63 -3787
- package/dist/server.d.ts +8 -0
- package/dist/server.js +66 -0
- package/package.json +40 -8
- package/src/cli.ts +0 -3
- package/src/createApiTemplate.ts +32 -92
- package/src/{appSyncResolverHandler.ts → createAppSyncResolverHandler.ts} +8 -2
- package/src/index.ts +4 -1
- package/src/server.ts +47 -0
- package/dist/esm/chunk-4HZVG2AW.js +0 -4498
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
__commonJS,
|
|
26
|
+
__toESM
|
|
27
|
+
};
|
package/dist/esm/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
import {
|
|
3
3
|
AppSyncGraphQLSchemaLogicalId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5MBGDEAO.js";
|
|
5
|
+
import "./chunk-NQOARNEJ.js";
|
|
5
6
|
|
|
6
7
|
// src/cli.ts
|
|
7
8
|
import * as fs from "fs";
|
|
@@ -11,7 +12,6 @@ var argv = minimist(process.argv.slice(2));
|
|
|
11
12
|
if (argv._.includes("build-schema")) {
|
|
12
13
|
const template = findAndReadCloudFormationTemplate({});
|
|
13
14
|
const sdl = template.Resources[AppSyncGraphQLSchemaLogicalId].Properties.Definition;
|
|
14
|
-
console.log(sdl);
|
|
15
15
|
fs.mkdirSync("schema", { recursive: true });
|
|
16
16
|
fs.writeFileSync("schema/schema.graphql", sdl);
|
|
17
17
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
import {
|
|
3
3
|
createApiTemplate
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5MBGDEAO.js";
|
|
5
|
+
import "./chunk-NQOARNEJ.js";
|
|
5
6
|
|
|
6
7
|
// src/index.ts
|
|
7
8
|
import { schemaComposer } from "graphql-compose";
|
|
8
9
|
|
|
9
|
-
// src/
|
|
10
|
-
var
|
|
10
|
+
// src/createAppSyncResolverHandler.ts
|
|
11
|
+
var createAppSyncResolverHandler = ({
|
|
11
12
|
schemaComposer: schemaComposer2
|
|
12
13
|
}) => {
|
|
13
14
|
return async (event, context) => {
|
|
@@ -18,7 +19,7 @@ var appSyncResolverHandler = ({
|
|
|
18
19
|
};
|
|
19
20
|
};
|
|
20
21
|
export {
|
|
21
|
-
appSyncResolverHandler,
|
|
22
22
|
createApiTemplate,
|
|
23
|
+
createAppSyncResolverHandler,
|
|
23
24
|
schemaComposer
|
|
24
25
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import "./chunk-NQOARNEJ.js";
|
|
3
|
+
|
|
4
|
+
// src/server.ts
|
|
5
|
+
import {
|
|
6
|
+
getGraphQLParameters,
|
|
7
|
+
processRequest,
|
|
8
|
+
renderGraphiQL,
|
|
9
|
+
sendResult,
|
|
10
|
+
shouldRenderGraphiQL
|
|
11
|
+
} from "graphql-helix";
|
|
12
|
+
import express from "express";
|
|
13
|
+
var createServer = ({
|
|
14
|
+
schemaComposer
|
|
15
|
+
}) => {
|
|
16
|
+
const server = express();
|
|
17
|
+
server.use(express.json());
|
|
18
|
+
server.use("/graphql", async (req, res) => {
|
|
19
|
+
const request = {
|
|
20
|
+
body: req.body,
|
|
21
|
+
headers: req.headers,
|
|
22
|
+
method: req.method,
|
|
23
|
+
query: req.query
|
|
24
|
+
};
|
|
25
|
+
if (shouldRenderGraphiQL(request)) {
|
|
26
|
+
res.send(renderGraphiQL());
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const { operationName, query, variables } = getGraphQLParameters(request);
|
|
30
|
+
const result = await processRequest({
|
|
31
|
+
operationName,
|
|
32
|
+
query,
|
|
33
|
+
variables,
|
|
34
|
+
request,
|
|
35
|
+
schema: schemaComposer.buildSchema()
|
|
36
|
+
});
|
|
37
|
+
sendResult(result, res);
|
|
38
|
+
});
|
|
39
|
+
return server;
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
createServer
|
|
43
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { SchemaComposer } from 'graphql-compose';
|
|
2
2
|
export { ResolverResolveParams, schemaComposer } from 'graphql-compose';
|
|
3
|
-
import { CloudFormationTemplate } from '
|
|
4
|
-
import { AppSyncResolverHandler } from 'aws-lambda';
|
|
3
|
+
import { CloudFormationTemplate } from '@ttoss/cloudformation';
|
|
4
|
+
import { AppSyncResolverHandler as AppSyncResolverHandler$1 } from 'aws-lambda';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type Role = string | {
|
|
7
|
+
'Fn::ImportValue': string;
|
|
8
|
+
};
|
|
9
|
+
declare const createApiTemplate: ({ schemaComposer, dataSource, lambdaFunction, }: {
|
|
7
10
|
schemaComposer: SchemaComposer<any>;
|
|
11
|
+
dataSource: {
|
|
12
|
+
roleArn: Role;
|
|
13
|
+
};
|
|
14
|
+
lambdaFunction: {
|
|
15
|
+
roleArn: Role;
|
|
16
|
+
};
|
|
8
17
|
}) => CloudFormationTemplate;
|
|
9
18
|
|
|
10
|
-
|
|
19
|
+
type AppSyncResolverHandler<TArguments, TResult, TSource = Record<string, any> | null> = AppSyncResolverHandler$1<TArguments, TResult, TSource>;
|
|
20
|
+
declare const createAppSyncResolverHandler: ({ schemaComposer, }: {
|
|
11
21
|
schemaComposer: SchemaComposer<any>;
|
|
12
22
|
}) => AppSyncResolverHandler<any, any, any>;
|
|
13
23
|
|
|
14
|
-
export {
|
|
24
|
+
export { AppSyncResolverHandler, createApiTemplate, createAppSyncResolverHandler };
|