Apollo Driver
Configure Apollo Server with drivers.apollo() in config/graphql.ts, toggle introspection and the playground, and register Apollo Server plugins
Apollo GraphQL is an enterprise-oriented GraphQL platform part of a large ecosystem. It is opinionated, feature-rich, optimized for large teams, production observability and schema governance.
Configuration
The Apollo driver is configured using the driver option with drivers.apollo() in your GraphQL configuration file. The configuration accepts all Apollo Server configuration options except for schema (which is automatically provided).
import env from '#start/env'
import { defineConfig, drivers } from '@foadonis/graphql'
const isDevelopment = env.get('NODE_ENV') === 'development'
export default defineConfig({
driver: drivers.apollo({
// Apollo server configuration
introspection: isDevelopment,
playground: isDevelopment,
}),
})It is highly recommended to disable the playground and introspection in production for security reasons as it exposes the available operations of your application.
Plugins
Apollo Server supports a powerful plugin system that allows you to extend the server's functionality. You can add plugins to handle logging, error reporting, caching, and more.
import { defineConfig, drivers } from '@foadonis/graphql'
import { ApolloServerPluginUsageReporting } from '@apollo/server/plugin/usageReporting'
export default defineConfig({
driver: drivers.apollo({
plugins: [
ApolloServerPluginUsageReporting({
sendVariableValues: { all: true },
}),
],
}),
})You can find more information about Apollo Server plugins in the official documentation.
Getting Started
Bootstrap a code-first API with @foadonis/graphql: choose the Yoga or Apollo driver, then write a Recipe type, a resolver and a query in the playground.
Yoga Driver
Set up GraphQL Yoga through drivers.yoga(), enable file uploads with the AdonisJS bodyparser processManually list and a File scalar, and add Yoga plugins