Skip to content

Commit ea4553e

Browse files
committed
Merge branch 'next' into main
2 parents b26bbfc + 34ad523 commit ea4553e

33 files changed

Lines changed: 306508 additions & 305571 deletions

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,50 @@
11
# Changelog
22

3+
## Version 1.0.0-beta.52
4+
5+
### ⚠️ Breaking
6+
7+
- Feat: Providing easier access to Prisma Client
8+
9+
```typescript
10+
// initialise client
11+
const app = new PrismaAppSync({
12+
connectionUrl: process.env.CONNECTION_URL
13+
})
14+
15+
// access Prisma client
16+
app.prisma.$use(async (params, next) => {
17+
console.log('This is middleware!')
18+
return next(params)
19+
})
20+
```
21+
22+
**Migration guide:**
23+
24+
- `app.$disconnect` replaced with `app.prisma.$disconnect`.
25+
- `prisma` parameter removed from the before and after hooks functions, as well as from the customResolvers parameters. To access prisma from within hooks, directly use `app.prisma`.
26+
27+
### Non-breaking
28+
29+
- Feat: Support for prisma ^2.21.2 added.
30+
- Feat: Lambda bundle size reduced (provided CDK boilerplate).
31+
32+
```typescript
33+
afterBundling(inputDir: string, outputDir: string): string[] {
34+
return [
35+
'npx prisma generate',
36+
'rm -rf node_modules/@prisma/engines',
37+
'rm -rf node_modules/@prisma/client/node_modules',
38+
'rm -rf node_modules/.bin',
39+
'rm -rf node_modules/prisma',
40+
'rm -rf node_modules/prisma-appsync',
41+
]
42+
}
43+
```
44+
45+
- Feat: Contribution guide added (see [CONTRIBUTING.md](CONTRIBUTING.md)) with new boilerplate testing workflow.
46+
- Feat: Core library is now using Pnpm instead of Yarn.
47+
348
## Version 1.0.0-beta.51
449

550
- Fix: Support for prisma ^2.20 added (output for generators can now be env vars).

CONTRIBUTING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contributing
2+
3+
## Bug Reports and Feature Requests
4+
5+
If you have found a bug or have a feature request then please create an issue in this repository (please search first in case a similar issue already exists).
6+
7+
## Code
8+
9+
### General Prerequisites
10+
11+
1. Node.js, [latest LTS is recommended](https://nodejs.org/en/about/releases/)
12+
2. Install [`pnpm`](https://pnpm.js.org/) (for installing dependencies)
13+
3. Install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) (for deploying on AWS)
14+
4. Install the [AWS CDK](https://github.com/aws/aws-cdk) (for deploying on AWS)
15+
5. Install [`yarn@1`](https://classic.yarnpkg.com/en/docs/install/) (for building the project before deploy)
16+
6. Install [`docker`](https://www.docker.com/products/docker-desktop) (for bundling the project before deploy)
17+
18+
### Dev Setup
19+
20+
To setup the project for local development, follow these steps:
21+
22+
```bash
23+
# clone the repo
24+
git clone https://github.com/maoosi/prisma-appsync.git
25+
26+
# install dependencies
27+
cd prisma-appsync
28+
pnpm install
29+
30+
# install cdk boilerplate dependencies
31+
pnpm install:boilerplate
32+
```
33+
34+
### Run Tests
35+
36+
To run the automated tests, follow these steps:
37+
38+
```bash
39+
# build project and run tests
40+
pnpm test
41+
```
42+
43+
### Test on AWS
44+
45+
To quickly create a test app using your local `prisma-appsync` directory, follow these steps:
46+
47+
```bash
48+
# make sure to run from the same level as `prisma-appsync` dir
49+
[ -d "./prisma-appsync" ] && echo "You are at the right location." || echo "Wrong location. Make sure to be at the same level as prisma-appsync dir."
50+
51+
# run the generator using the --test parameter
52+
yarn create prisma-appsync-app . --test
53+
54+
# cd into the new test app folder
55+
cd prisma-appsync-testapp-<timestamp>
56+
57+
# run prisma generate and deploy on AWS
58+
yarn deploy
59+
```
60+
61+
> Please note that `yarn create prisma-appsync-app . --test` will use a special version of the Prisma-AppSync boilerplate that will automatically link the prisma-appsync dependency to your local dev setup (`prisma-appsync` directory located at the same level).
62+
63+
## Legal
64+
65+
By submitting your code to the Prisma-AppSync project, you are granting the project maintainers a right to use that code and provide it to others under the BSD 2-Clause License attached to the project. You are also certifying that you wrote it, and that you are allowed to license it to us.

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
## ⚓ Compatibility
2828

29-
- Prisma 2.10.1
29+
- Prisma 2.21.2
3030

3131
## 📓 Documentation
3232

@@ -39,12 +39,20 @@
3939
## 🧙‍♂️ Contributors
4040

4141
<table>
42-
<tr>
43-
<td align="center" style="border:0;">
44-
<a href="https://github.com/maoosi" target="_blank">
45-
<img src="https://avatars2.githubusercontent.com/u/4679377?v=3?s=120" width="120px;" alt="maoosi"/>
46-
<br /><sub><b>Sylvain (maoosi)</b></sub>
47-
</a>
42+
<tr>
43+
<td align="center">
44+
<div>
45+
<sub><b>Owner/Maintainer</b></sub>
46+
</div>
47+
<div>
48+
<a href="https://github.com/maoosi" target="_blank">
49+
<img src="https://avatars2.githubusercontent.com/u/4679377?v=3?s=120" width="120px;" alt="maoosi"/>
50+
<br /><sub><b>Sylvain (@maoosi)</b></sub>
51+
</a>
52+
</div>
53+
<div>
54+
<a href="https://www.buymeacoffee.com/maoosi" target="_blank"><sub>☕ Buy me a coffee</sub></a>
55+
</div>
4856
</td>
4957
</tr>
5058
</table>
@@ -53,7 +61,7 @@
5361

5462
<table>
5563
<tr>
56-
<td align="center" style="border:0;width:200px;">
64+
<td align="center" style="width:200px;">
5765
<a href="https://travistravis.co" target="_blank">
5866
<img src="https://prisma-appsync.vercel.app/travistravis.co.png" width="160px;" alt="travistravis.co"/>
5967
<br /><b>Travis</b>

boilerplate/cdk/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,37 @@ export class AppSyncCdkStack extends cdk.Stack {
9090
const lambdaFunction = new NodejsFunction(this, `${process.env.SERVICES_PREFIX}_Function`, {
9191
functionName: `${process.env.SERVICES_PREFIX}_Function`,
9292
role: lambdaExecutionRole,
93-
runtime: Runtime.NODEJS_12_X,
93+
runtime: Runtime.NODEJS_14_X,
9494
timeout: cdk.Duration.seconds(10),
9595
handler: 'main',
9696
entry: path.join(__dirname, process.env.HANDLER_FUNCTION_PATH || ``),
97-
memorySize: 512,
97+
memorySize: 1536,
9898
depsLockFilePath: path.join(__dirname, '../yarn.lock'),
9999
bundling: {
100100
minify: true,
101101
commandHooks: {
102102
beforeBundling(inputDir: string, outputDir: string): string[] {
103-
const schemaPath = path.join(
104-
inputDir, process.env.PRISMA_SCHEMA_ROOT_PATH || 'schema.prisma'
105-
)
106-
return [`cp ${schemaPath} ${outputDir}`]
103+
return [
104+
`cp ${path.join(inputDir, process.env.PRISMA_SCHEMA_ROOT_PATH || 'schema.prisma')} ${outputDir}`
105+
]
107106
},
108107
beforeInstall() {
109108
return []
110109
},
111-
afterBundling() {
110+
afterBundling(inputDir: string, outputDir: string): string[] {
112111
return [
113-
'npx prisma generate',
114-
'rm -rf node_modules/prisma/query-engine-darwin',
115-
'rm -rf node_modules/prisma/query-engine-rhel-openssl-1.0.x'
112+
<% if (testingMode) { %>`cp -R ${path.join(inputDir, 'node_modules/.tmp/prisma-appsync/')} ${path.join(outputDir, 'node_modules/')}`,
113+
<% } %>'npx prisma generate',
114+
'rm -rf node_modules/@prisma/engines',
115+
'rm -rf node_modules/@prisma/client/node_modules',
116+
'rm -rf node_modules/.bin',
117+
'rm -rf node_modules/prisma',
118+
'rm -rf node_modules/prisma-appsync',
116119
]
117120
}
118121
},
119-
nodeModules: ['prisma', '@prisma/client', 'prisma-appsync'],
122+
<% if (testingMode) { %>nodeModules: ['prisma', '@prisma/client'],<% } else { %>nodeModules: ['prisma', '@prisma/client', 'prisma-appsync'],<% } %>
123+
forceDockerBundling: true
120124
},
121125
environment: {
122126
CONNECTION_URL: process.env.PRISMA_CONNECTION_URL || ``
@@ -164,7 +168,7 @@ export class AppSyncCdkStack extends cdk.Stack {
164168
)
165169

166170
// read resolvers from yaml
167-
const resolvers = yaml.safeLoad(
171+
const resolvers = yaml.load(
168172
fs.readFileSync(
169173
path.join(__dirname, process.env.APPSYNC_RESOLVERS_PATH || ``),
170174
'utf8'

0 commit comments

Comments
 (0)