Skip to content

Commit

Permalink
Merge pull request #48 from howtographql/prisma-client
Browse files Browse the repository at this point in the history
Prisma client
  • Loading branch information
nikolasburk committed Dec 17, 2018
2 parents e99dba0 + 372e6c4 commit dfbba75
Show file tree
Hide file tree
Showing 20 changed files with 4,588 additions and 2,068 deletions.
10 changes: 0 additions & 10 deletions .graphqlconfig.yml

This file was deleted.

48 changes: 9 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,24 @@ cd graphql-js
yarn install # or `npm install`
```

### 2. Deploy the Prisma database service
### 2. Install the Prisma CLI

```sh
yarn prisma deploy
yarn global add prisma
```

When prompted where (i.e. to which Prisma server) you want to deploy your service, choose the Demo server which can be used for free in Prisma Cloud. If you haven't done so already, you will be asked to register with Prisma Cloud (which you can do via GitHub). For the following prompts in the terminal you can select the suggested values by hitting Enter. (If you have Docker installed, you can also choose to deploy Prisma locally by Creating a new database.)
### 3. Deploy the Prisma database service

### 3. Set the Prisma service endpoint

From the output of the previous command, copy the `HTTP` endpoint and paste it into `src/index.js` where it's used to instantiate the `Prisma` binding. You need to replace the current placeholder `__PRISMA_ENDPOINT__`:

```js
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: req => ({
...req,
db: new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: "__PRISMA_ENDPOINT__",
debug: true
}),
}),
})
```sh
prisma deploy
```

For example:

```js
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: req => ({
...req,
db: new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: "https://eu1.prisma.sh/john-dpe/hackernews-graphql-js/dev",
debug: true,
}),
}),
})
```
When prompted where (i.e. to which Prisma server) you want to deploy your service, choose the **Demo server** which can be used for free in Prisma Cloud. If you haven't done so already, you will be asked to register with Prisma Cloud (which you can do via GitHub). For the following prompts in the terminal you can select the suggested values by hitting Enter. (If you have Docker installed, you can also choose to deploy Prisma locally by creating a new database.)

### 4. Start the server & open Playground

To interact with the API in a GraphQL Playground, all you need to do is execute the `dev` script defined in `package.json`:
To interact with the API in a GraphQL Playground, all you need to do is execute the `start` script defined in `package.json`:

```sh
yarn dev
```
yarn start
```
6 changes: 0 additions & 6 deletions database/prisma.yml

This file was deleted.

14 changes: 2 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
{
"name": "hackernews-node",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "node src/index.js",
"dev": "npm-run-all --parallel start playground",
"playground": "graphql playground",
"prisma": "prisma",
"graphql": "graphql"
"start": "node src/index.js"
},
"dependencies": {
"bcryptjs": "^2.4.3",
"graphql-yoga": "^1.7.0",
"jsonwebtoken": "^8.2.0",
"prisma-binding": "^2.0.2"
},
"devDependencies": {
"graphql-cli": "^2.16.4",
"npm-run-all": "^4.1.2",
"prisma": "^1.9.0"
"prisma-client-lib": "^1.22.2"
}
}
File renamed without changes.
8 changes: 8 additions & 0 deletions prisma/prisma.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
datamodel: datamodel.prisma
generate:
- generator: javascript-client
output: ../src/generated/prisma-client
secret: mysecret123
hooks:
post-deploy:
- prisma generate
Loading

0 comments on commit dfbba75

Please sign in to comment.