apollo-server/docs/source/deployment/now.md

58 lines
1.7 KiB
Markdown
Raw Normal View History

2018-06-28 15:21:54 +01:00
---
title: Deploying with Zeit Now
sidebar_title: Now
description: Deploying your GraphQL server to Zeit Now
---
2018-06-28 16:20:25 +01:00
Now is a service by Zeit that allows the deployment of an instance of Apollo Server, which provides a functional GraphQL endpoint.
2018-06-28 15:21:54 +01:00
## Node.js Deployment
2018-06-28 16:20:25 +01:00
Deployment to Now for Node.js apps simply requires a `package.json` file to be present in your app directory.
2018-06-28 15:21:54 +01:00
```js
{
"name": "graphqlservice",
"version": "1.0.0",
"scripts": {
"start": "nodemon index.js"
},
2018-06-28 15:21:54 +01:00
"dependencies": {
"apollo-server": "^2.0.0-rc.5",
"graphql": "^0.13.2",
"nodemon": "^1.17.5"
2018-06-28 15:21:54 +01:00
}
}
```
2018-06-28 15:35:11 +01:00
### Deploy server to Now
2018-06-28 15:21:54 +01:00
2018-06-28 16:13:36 +01:00
Install the [now CLI](https://zeit.co/download#now-cli), then visit your server directory and run the `now` command:
2018-06-28 15:21:54 +01:00
```sh
$ now
```
2018-06-28 15:35:11 +01:00
The `now` command immediately deploys your server to the cloud and returns the hosted project link. Send a query to your GraphQL server on `now` at `<NOW_APP_NAME>.now.sh`.
2018-06-28 15:21:54 +01:00
2018-06-28 15:35:11 +01:00
### Deploying directly from GitHub
2018-06-28 15:21:54 +01:00
If you have your GraphQL server published to GitHub, Now provides the ability to deploy straight from GitHub to the cloud.
2018-06-28 15:21:54 +01:00
2018-06-28 16:13:36 +01:00
Assuming you'd like to deploy an instance of [apollo](https://github.com/apollographql)'s [graphql-server-example](https://github.com/apollographql/graphql-server-example), this is what you'll do:
2018-06-28 15:21:54 +01:00
```sh
2018-06-28 16:13:36 +01:00
$ now apollographql/graphql-server-example
2018-06-28 15:21:54 +01:00
```
2018-06-28 16:13:36 +01:00
The `now` command deploys right away and gets the server up and running on the cloud. Furthermore, running the following command will automatically start delivering reports to Apollo Engine.
2018-06-28 15:21:54 +01:00
```sh
2018-06-28 16:13:36 +01:00
$ now -e ENGINE_API_KEY=xxxxxxxxx apollographql/graphql-server-example
2018-06-28 15:21:54 +01:00
```
<div style="text-align:center">
![Deployed GraphQL Server](../images/deployment/zeit/zeit-apollo-server.png)
<br></br>
</div>