mirror of
https://github.com/vale981/apollo-server
synced 2025-03-05 17:51:40 -05:00
Update README.md with the latest package name (#1936)
This commit is contained in:
parent
0d6b8f24e6
commit
d81ae051e7
1 changed files with 7 additions and 7 deletions
|
@ -3,22 +3,22 @@ title: Google Cloud Functions
|
|||
description: Setting up Apollo Server with Google Cloud Functions
|
||||
---
|
||||
|
||||
[](https://badge.fury.io/js/apollo-server-cloud-function) [](https://circleci.com/gh/apollographql/apollo-server) [](https://coveralls.io/github/apollographql/apollo-server?branch=master) [](https://www.apollographql.com/#slack)
|
||||
[](https://badge.fury.io/js/apollo-server-cloud-functions) [](https://circleci.com/gh/apollographql/apollo-server) [](https://coveralls.io/github/apollographql/apollo-server?branch=master) [](https://www.apollographql.com/#slack)
|
||||
|
||||
This is the Google Cloud Function integration of GraphQL Server. Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP server frameworks. [Read the docs](https://www.apollographql.com/docs/apollo-server/v2). [Read the CHANGELOG](https://github.com/apollographql/apollo-server/blob/master/CHANGELOG.md).
|
||||
|
||||
```sh
|
||||
npm install apollo-server-cloud-function@rc graphql
|
||||
npm install apollo-server-cloud-functions graphql
|
||||
```
|
||||
|
||||
## Deploying with Google Cloud Function
|
||||
|
||||
#### 1. Write the API handlers
|
||||
|
||||
First, create a `package.json` file and include `apollo-server-cloud-function` in your dependencies. Then in a file named `index.js`, place the following code:
|
||||
First, create a `package.json` file and include `apollo-server-cloud-functions` in your dependencies. Then in a file named `index.js`, place the following code:
|
||||
|
||||
```js
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-function');
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-functions');
|
||||
|
||||
// Construct a schema, using GraphQL schema language
|
||||
const typeDefs = gql`
|
||||
|
@ -60,7 +60,7 @@ You can refer to the [Cloud Functions documentation](https://cloud.google.com/fu
|
|||
To read information about the currently executing Google Cloud Function (HTTP headers, HTTP method, body, path, ...) use the context option. This way you can pass any request specific data to your schema resolvers.
|
||||
|
||||
```js
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-function');
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-functions');
|
||||
|
||||
// Construct a schema, using GraphQL schema language
|
||||
const typeDefs = gql`
|
||||
|
@ -94,7 +94,7 @@ exports.handler = server.createHandler();
|
|||
To enable CORS the response HTTP headers need to be modified. To accomplish this use the `cors` option.
|
||||
|
||||
```js
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-function');
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-functions');
|
||||
|
||||
// Construct a schema, using GraphQL schema language
|
||||
const typeDefs = gql`
|
||||
|
@ -126,7 +126,7 @@ exports.handler = server.createHandler({
|
|||
To enable CORS response for requests with credentials (cookies, http authentication) the allow origin header must equal the request origin and the allow credential header must be set to true.
|
||||
|
||||
```js
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-function');
|
||||
const { ApolloServer, gql } = require('apollo-server-cloud-functions');
|
||||
|
||||
// Construct a schema, using GraphQL schema language
|
||||
const typeDefs = gql`
|
||||
|
|
Loading…
Add table
Reference in a new issue