Skip to content

Commit 78861b7

Browse files
author
Isac Casapu
committed
Implement the plug-in
1 parent dfc69c6 commit 78861b7

8 files changed

+1386
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
88

9+
# Compiled JS
10+
build/
11+
912
# Diagnostic reports (https://nodejs.org/api/report.html)
1013
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1114

README.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
postgraphile-plugin-aws-appsync-scalars
2+
=======================================
3+
4+
5+
This plugin for PostGraphile converts Postgraphile-generated custom scalar names to those AWS AppSync accepts.
6+
7+
Current name mappings:
8+
9+
| PostGraphile type | AWS type |
10+
|-------------------|----------|
11+
| JSON | AWSJSON |
12+
| Datetime | AWSDateTime |
13+
| Date | AWSDate |
14+
| Cursor | String |
15+
16+
17+
Limitations
18+
-----------
19+
20+
No warning is issued if you failed to set dynamic-json to false. In that case,
21+
the resulting schema will presented by AWS AppSync will not match what PostGrahile expects to receive.
22+
23+
24+
Installation
25+
------------
26+
27+
Install using NPM or Yarn.
28+
29+
NPM:
30+
31+
```bash
32+
npm install --save @cloudcycle/postgraphile-plugin-aws-appsync-scalars
33+
```
34+
35+
Yarn:
36+
```bash
37+
yarn add @cloudcycle/postgraphile-plugin-aws-appsync-scalars
38+
```
39+
40+
Usage
41+
-----
42+
43+
CLI:
44+
45+
```bash
46+
postgraphile --dynamic-json false --append-plugins @cloudcycle/postgraphile-plugin-aws-appsync-scalars
47+
```
48+
49+
Library:
50+
51+
```javascript
52+
import awsAppsyncScalarsPlugin from '@cloudcycle/postgraphile-plugin-aws-appsync-scalars';
53+
```
54+
55+
Then add it to the appendPlugins array. E.g.:
56+
57+
```javascript
58+
app.use(
59+
postgraphile(process.env.AUTH_DATABASE_URL, "app_public", {
60+
appendPlugins: [awsAppsyncScalarsPlugin],
61+
dynamicJson: false,
62+
63+
// Optional customisation
64+
graphileBuildOptions: {
65+
/*
66+
* Uncomment if you want simple collections to lose the 'List' suffix
67+
* (and connections to gain a 'Connection' suffix).
68+
*/
69+
//pgOmitListSuffix: true,
70+
/*
71+
* Uncomment if you want 'userPatch' instead of 'patch' in update
72+
* mutations.
73+
*/
74+
//pgSimplifyPatch: false,
75+
/*
76+
* Uncomment if you want 'allUsers' instead of 'users' at root level.
77+
*/
78+
//pgSimplifyAllRows: false,
79+
/*
80+
* Uncomment if you want primary key queries and mutations to have
81+
* `ById` (or similar) suffix; and the `nodeId` queries/mutations
82+
* to lose their `ByNodeId` suffix.
83+
*/
84+
// pgShortPk: true,
85+
},
86+
// ... other settings ...
87+
})
88+
);
89+
```
90+
91+
Roadmap
92+
-------
93+
94+
* Add unit tests
95+
* Allow user-specified types (e.g. SQL domains) to be converted.
96+
* Allow AWS types for fields, arguments etc. to be specified via smart-comments, so
97+
that we could make use of the extra checking AWS AppSync performs when using AWSEmail,
98+
AWSPhone etc.

0 commit comments

Comments
 (0)