Apollo configuration

This library is based on apollo-server. You can configure the Apollo server with all the possible configuration of basic usage.

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
        }
      }
    }
})

Last updated

Was this helpful?