prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
673 stars 66 forks source link

Use serverless framework #760

Open kokokenada opened 4 years ago

kokokenada commented 4 years ago

Perceived Problem

Lots options for deployment each having their own configuration. Users want out of the box magic for whatever target environment.

Ideas / Proposed Solution(s)

Give users a lot of choices to deploy to a variety of targets by using the open source parts of the serverless framework. The community can develop templates/starters.

Create standard approach to dev/staging/prod CICD pipeline.

Kind of an unformed idea here, but I thought I'd pass it on having used the serverless framework in a recent project and thought it was pretty good.

jasonkuhrt commented 4 years ago

I think we can explore this better once we have #782.

jasonkuhrt commented 4 years ago

Relevant https://twitter.com/goserverless/status/1265613724024438784

leungandrew commented 4 years ago

I'm super interested in getting a Nexus + Prisma app to run in the above deploying to Serverless Express. I've made enough progress to the point where I have the Playground and GraphQL endpoints working (which imply that the express server is running properly).

Some minor tweaks I had to make from the scaffolded app produced via npx nexus are to move the app.js file to the rootDir, update tsconfig to compile from the rootDir ., and in app.js the following:

import app, { server, use } from 'nexus'
import { prisma } from 'nexus-plugin-prisma'

use(prisma({ features: { crud: true } }))

require('./api/graphql')
app.assemble()

module.exports = server.express

The module.exports is required by the express serverless component as it expects the the app.js to export the express server. (And also that the app.js lives at the rootDir or it won't find the express app).

The last issue I'm running into seems to be Prisma specific however, as for some reason, even though I've set the binaryTarget for Prisma when running on AWS Lambda to be rhel-openssl-1.0.x, I get the following error:

"\nInvalid `prisma.user.findMany()` invocation in\n/var/task/node_modules/nexus-prisma/dist/builder.js:202:93\n\n\n  EROFS: read-only file system, chmod '/var/task/node_modules/.prisma/client/query-engine-rhel-openssl-1.0.x'"

I wonder if it has anything to do with https://github.com/prisma/prisma-client-js/issues/476, however that implies it's a Windows issue, whereas I'm deploying via macOS.