Skip to content

Commit

Permalink
Add note about standalone server's 50mb default body-parser limit
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer committed Nov 19, 2022
1 parent 93d24a4 commit 1c0224f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/source/api/standalone.mdx
Expand Up @@ -9,7 +9,7 @@ This API reference documents the `startStandaloneServer` function.

## Overview

This `startStandaloneServer` function helps you get started with Apollo Server quickly. This function is recommended for all projects that don't require serverless support or a particular Node.js framework (such as Fastify). Under the hood, the `startStandaloneServer` function uses Apollo Server 4's Express integration (i.e., [`expressMiddleware`](./express-middleware)).
This `startStandaloneServer` function helps you get started with Apollo Server quickly. This function is recommended for all projects that don't require serverless support or a particular Node.js framework (such as Fastify). Under the hood, the `startStandaloneServer` function uses Apollo Server 4's Express integration (i.e., [`expressMiddleware`](./express-middleware)).

Because it sets helpful defaults, this function is less configurable than other Apollo Server integrations. Complex projects might eventually need to [swap to using `expressMiddleware`](#swapping-to-expressmiddleware) (this process is straightforward).

Expand All @@ -30,7 +30,7 @@ const server = new ApolloServer({ typeDefs, resolvers });
// `startStandaloneServer` returns a `Promise` with the
// the URL that the server is listening on.
const { url } = await startStandaloneServer(server); //highlight-line
```
```

</MultiCodeBlock>

Expand Down Expand Up @@ -59,7 +59,7 @@ The `startStandaloneServer` function's second optional argument is an object for

<td>

An optional asynchronous [`context` initialization function](../data/resolvers#the-context-argument).
An optional asynchronous [`context` initialization function](../data/resolvers#the-context-argument).

The `context` function should return an object that all your server's resolvers share during an operation's execution. This enables resolvers to share helpful context values, such as a database connection.

Expand Down Expand Up @@ -91,7 +91,7 @@ If no `port` is specified, this defaults to using `{port: 4000}`.
</tbody>
</table>

### Example
### Example

Below is a full example of setting up `startStandaloneServer`:

Expand Down Expand Up @@ -196,7 +196,8 @@ await server.start();
// and our expressMiddleware function.
app.use('/',
cors<cors.CorsRequest>(),
bodyParser.json(),
// 50mb is the limit that `startStandaloneServer` uses, but you may configure this to suit your needs
bodyParser.json({ limit: '50mb' }),
// expressMiddleware accepts the same arguments:
// an Apollo Server instance and optional configuration options
expressMiddleware(server, {
Expand All @@ -208,4 +209,4 @@ app.use('/',
await new Promise<void>(resolve => httpServer.listen({ port: 4000 }, resolve));
console.log(`馃殌 Server ready at http://localhost:4000/`);
```
</MultiCodeBlock>
</MultiCodeBlock>

0 comments on commit 1c0224f

Please sign in to comment.