Giter Site home page Giter Site logo

nexus-prisma-serverless-express's Introduction

Setup

yarn install
yarn build

If you already have your own Postgres DB spun up, then add a prisma/.env with your DATABASE_URL=postgres://yadayada and run:

yarn -s prisma migrate up --experimental
yarn -s prisma generate
yarn -s ts-node prisma/seed.ts

Run the server locally:

DATABASE_URL=<your-postgres-db> yarn start

Check that it works locally, then deploy to serverless:

yarn deploy

Excerpt of yarn deploy:

    "deploy:export": "echo \"module.exports = nexus_1.server.express\" >> .nexus/build/index.js",
    "deploy:rename": "mv .nexus/build/index.js .nexus/build/app.js",
    "deploy": "yarn deploy:export && yarn deploy:rename && serverless deploy",

Notes

Serverless Express component expects an app.js that exports the express server, which is what the deploy:export script does.

Secondly, we rename the index.js to app.js so Serverless picks up the entrypoint correctly.

This should lead you to a playground that works with the schema well defined. But you will notice that when making a query, the following error appears:

{
  "error": {
    "errors": [
      {
        "message": "\nInvalid `prisma.world.findMany()` invocation in\n/var/task/api/graphql.js:46:37\n\n\n  EROFS: read-only file system, chmod '/var/task/node_modules/.prisma/client/query-engine-rhel-openssl-1.0.x'",
        "locations": [
          {
            "line": 2,
            "column": 3
          }
        ],
        "path": [
          "worlds"
        ]
      }
    ],
    "data": {
      "worlds": null
    }
  }
}

Second note: I realize that we haven't exposed the DATABASE_URL to Serverless yet at this point. This is as simple as adding:

inputs:
  env:
    DATABASE_URL: "postgres://yadayada"

to the serverless.yml

but because we can't get past the above error, we won't see the error where Prisma can't find the database.

nexus-prisma-serverless-express's People

Contributors

leungandrew avatar

Stargazers

Austen  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.