Skip to content

Commit bd2f740

Browse files
committed
update README
1 parent 83f8939 commit bd2f740

File tree

2 files changed

+53
-13
lines changed

2 files changed

+53
-13
lines changed

README.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,68 @@ git clone https://github.com/howtographql/react-apollo/
1111
cd react-apollo
1212
```
1313

14-
### 2. Create GraphQL API with [`graphcool`](https://www.npmjs.com/package/graphcool)
15-
16-
If you haven't already, install the Graphcool CLI:
14+
### 2. Deploy the Prisma database service
1715

1816
```sh
19-
# Install Graphcool CLI
20-
npm install -g graphcool
17+
cd server
18+
prisma deploy
19+
```
20+
21+
> You can use the `prisma` CLI without having it globally installed because it's listed as a _development dependency_ in `package.json`.
22+
23+
When prompted where (i.e. to which _cluster_) you want to deploy your service, choose any of the public clusters, e.g. `public-us1` or `public-eu1`. (If you have Docker installed, you can also deploy locally.)
24+
25+
### 3. Set the Prisma service endpoint
26+
27+
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`:
28+
29+
```js
30+
const server = new GraphQLServer({
31+
typeDefs: './src/schema.graphql',
32+
resolvers,
33+
context: req => ({
34+
...req,
35+
db: new Prisma({
36+
typeDefs: 'src/generated/prisma.graphql',
37+
endpoint: "__PRISMA_ENDPOINT__",
38+
secret: 'mysecret123',
39+
}),
40+
}),
41+
})
2142
```
2243

23-
Once it's installed, you can start the GraphQL server:
44+
For example:
45+
46+
```js
47+
const server = new GraphQLServer({
48+
typeDefs: './src/schema.graphql',
49+
resolvers,
50+
context: req => ({
51+
...req,
52+
db: new Prisma({
53+
typeDefs: 'src/generated/prisma.graphql',
54+
endpoint: "https://eu1.prisma.sh/public-hillcloak-flier-942261/hackernews-graphql-js/dev",
55+
secret: 'mysecret123',
56+
}),
57+
}),
58+
})
59+
```
60+
61+
Note that the part `public-hillcloak-flier-952361` of the URL is unique to your service.
62+
63+
### 4. Start the server
64+
65+
To start the server, all you need to do is execute the `start` script by running the following command inside the `server` directory:
2466

2567
```sh
26-
cd server
27-
yarn install
28-
graphcool deploy
2968
yarn start
3069
```
3170

32-
### 3. Install dependencies & run locally
71+
### 5. Run the app
72+
73+
Now that the server is running, you can run the app as well:
3374

3475
```sh
3576
cd ..
36-
yarn install
37-
yarn start # open http://localhost:3000 in your browser
77+
yarn start
3878
```

server/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const server = new GraphQLServer({
1919
...req,
2020
db: new Prisma({
2121
typeDefs: 'src/generated/prisma.graphql',
22-
endpoint: "https://eu1.prisma.sh/public-hillcloak-flier-952261/hackernews-graphql-js/dev",
22+
endpoint: "__PRISMA_ENDPOINT__",
2323
secret: 'mysecret123',
2424
}),
2525
}),

0 commit comments

Comments
 (0)