# Apollo configuration

This library is based on [apollo-server](https://www.npmjs.com/package/apollo-server). You can configure the Apollo server with all the possible configuration of basic usage.

```javascript
const server = generateApolloServer({
    // Here is an example of an apollo server configuration
    apolloServerOptions: {
      playground: true,
      // Example of context modification.
      context: ({ req, connection }) => {
        const contextDataloader = createContext(models.sequelize)

        // Connection is provided when a webSocket is connected.
        if (connection) {
          // check connection for metadata
          return {
            ...connection.context,
            [EXPECTED_OPTIONS_KEY]: contextDataloader
          }
        }

        // This is an example of context manipulation.
        return {
          ...req,
          bootDate: '2017-01-01',
          [EXPECTED_OPTIONS_KEY]: contextDataloader
        }
      },
      // Example of socket security hook.
      subscriptions: {
        onConnect: (connectionParams, webSocket) => {
          return true
        }
      }
    }
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vincent-desmares.gitbook.io/graphql-sequelize-generator/server/apollo-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
