|
| 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