Skip to content

Commit

Permalink
Merge branch 'next' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
maoosi committed Apr 25, 2021
2 parents b26bbfc + 34ad523 commit ea4553e
Show file tree
Hide file tree
Showing 33 changed files with 306,508 additions and 305,571 deletions.
67 changes: 0 additions & 67 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Changelog

## Version 1.0.0-beta.52

### ⚠️ Breaking

- Feat: Providing easier access to Prisma Client

```typescript
// initialise client
const app = new PrismaAppSync({
connectionUrl: process.env.CONNECTION_URL
})

// access Prisma client
app.prisma.$use(async (params, next) => {
console.log('This is middleware!')
return next(params)
})
```

**Migration guide:**

- `app.$disconnect` replaced with `app.prisma.$disconnect`.
- `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`.

### Non-breaking

- Feat: Support for prisma ^2.21.2 added.
- Feat: Lambda bundle size reduced (provided CDK boilerplate).

```typescript
afterBundling(inputDir: string, outputDir: string): string[] {
return [
'npx prisma generate',
'rm -rf node_modules/@prisma/engines',
'rm -rf node_modules/@prisma/client/node_modules',
'rm -rf node_modules/.bin',
'rm -rf node_modules/prisma',
'rm -rf node_modules/prisma-appsync',
]
}
```

- Feat: Contribution guide added (see [CONTRIBUTING.md](CONTRIBUTING.md)) with new boilerplate testing workflow.
- Feat: Core library is now using Pnpm instead of Yarn.

## Version 1.0.0-beta.51

- Fix: Support for prisma ^2.20 added (output for generators can now be env vars).
Expand Down
65 changes: 65 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Contributing

## Bug Reports and Feature Requests

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

## Code

### General Prerequisites

1. Node.js, [latest LTS is recommended](https://nodejs.org/en/about/releases/)
2. Install [`pnpm`](https://pnpm.js.org/) (for installing dependencies)
3. Install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) (for deploying on AWS)
4. Install the [AWS CDK](https://github.com/aws/aws-cdk) (for deploying on AWS)
5. Install [`yarn@1`](https://classic.yarnpkg.com/en/docs/install/) (for building the project before deploy)
6. Install [`docker`](https://www.docker.com/products/docker-desktop) (for bundling the project before deploy)

### Dev Setup

To setup the project for local development, follow these steps:

```bash
# clone the repo
git clone https://github.com/maoosi/prisma-appsync.git

# install dependencies
cd prisma-appsync
pnpm install

# install cdk boilerplate dependencies
pnpm install:boilerplate
```

### Run Tests

To run the automated tests, follow these steps:

```bash
# build project and run tests
pnpm test
```

### Test on AWS

To quickly create a test app using your local `prisma-appsync` directory, follow these steps:

```bash
# make sure to run from the same level as `prisma-appsync` dir
[ -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."

# run the generator using the --test parameter
yarn create prisma-appsync-app . --test

# cd into the new test app folder
cd prisma-appsync-testapp-<timestamp>

# run prisma generate and deploy on AWS
yarn deploy
```

> 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).
## Legal

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.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

## ⚓ Compatibility

- Prisma 2.10.1
- Prisma 2.21.2

## 📓 Documentation

Expand All @@ -39,12 +39,20 @@
## 🧙‍♂️ Contributors

<table>
<tr>
<td align="center" style="border:0;">
<a href="https://github.com/maoosi" target="_blank">
<img src="https://avatars2.githubusercontent.com/u/4679377?v=3?s=120" width="120px;" alt="maoosi"/>
<br /><sub><b>Sylvain (maoosi)</b></sub>
</a>
<tr>
<td align="center">
<div>
<sub><b>Owner/Maintainer</b></sub>
</div>
<div>
<a href="https://github.com/maoosi" target="_blank">
<img src="https://avatars2.githubusercontent.com/u/4679377?v=3?s=120" width="120px;" alt="maoosi"/>
<br /><sub><b>Sylvain (@maoosi)</b></sub>
</a>
</div>
<div>
<a href="https://www.buymeacoffee.com/maoosi" target="_blank"><sub>☕ Buy me a coffee</sub></a>
</div>
</td>
</tr>
</table>
Expand All @@ -53,7 +61,7 @@

<table>
<tr>
<td align="center" style="border:0;width:200px;">
<td align="center" style="width:200px;">
<a href="https://travistravis.co" target="_blank">
<img src="https://prisma-appsync.vercel.app/travistravis.co.png" width="160px;" alt="travistravis.co"/>
<br /><b>Travis</b>
Expand Down
28 changes: 16 additions & 12 deletions boilerplate/cdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,37 @@ export class AppSyncCdkStack extends cdk.Stack {
const lambdaFunction = new NodejsFunction(this, `${process.env.SERVICES_PREFIX}_Function`, {
functionName: `${process.env.SERVICES_PREFIX}_Function`,
role: lambdaExecutionRole,
runtime: Runtime.NODEJS_12_X,
runtime: Runtime.NODEJS_14_X,
timeout: cdk.Duration.seconds(10),
handler: 'main',
entry: path.join(__dirname, process.env.HANDLER_FUNCTION_PATH || ``),
memorySize: 512,
memorySize: 1536,
depsLockFilePath: path.join(__dirname, '../yarn.lock'),
bundling: {
minify: true,
commandHooks: {
beforeBundling(inputDir: string, outputDir: string): string[] {
const schemaPath = path.join(
inputDir, process.env.PRISMA_SCHEMA_ROOT_PATH || 'schema.prisma'
)
return [`cp ${schemaPath} ${outputDir}`]
return [
`cp ${path.join(inputDir, process.env.PRISMA_SCHEMA_ROOT_PATH || 'schema.prisma')} ${outputDir}`
]
},
beforeInstall() {
return []
},
afterBundling() {
afterBundling(inputDir: string, outputDir: string): string[] {
return [
'npx prisma generate',
'rm -rf node_modules/prisma/query-engine-darwin',
'rm -rf node_modules/prisma/query-engine-rhel-openssl-1.0.x'
<% if (testingMode) { %>`cp -R ${path.join(inputDir, 'node_modules/.tmp/prisma-appsync/')} ${path.join(outputDir, 'node_modules/')}`,
<% } %>'npx prisma generate',
'rm -rf node_modules/@prisma/engines',
'rm -rf node_modules/@prisma/client/node_modules',
'rm -rf node_modules/.bin',
'rm -rf node_modules/prisma',
'rm -rf node_modules/prisma-appsync',
]
}
},
nodeModules: ['prisma', '@prisma/client', 'prisma-appsync'],
<% if (testingMode) { %>nodeModules: ['prisma', '@prisma/client'],<% } else { %>nodeModules: ['prisma', '@prisma/client', 'prisma-appsync'],<% } %>
forceDockerBundling: true
},
environment: {
CONNECTION_URL: process.env.PRISMA_CONNECTION_URL || ``
Expand Down Expand Up @@ -164,7 +168,7 @@ export class AppSyncCdkStack extends cdk.Stack {
)

// read resolvers from yaml
const resolvers = yaml.safeLoad(
const resolvers = yaml.load(
fs.readFileSync(
path.join(__dirname, process.env.APPSYNC_RESOLVERS_PATH || ``),
'utf8'
Expand Down
Loading

1 comment on commit ea4553e

@vercel
Copy link

@vercel vercel bot commented on ea4553e Apr 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.