Examples
Learn from complete, working examples that demonstrate common patterns. All examples are part of the monorepo and can be run directly.
Running Examples
Section titled “Running Examples”# Clone the repositorygit clone https://github.com/nrf110/effect-gql.git# Install dependenciespnpm install
# Build all packages firstpnpm build
# Run an examplepnpm example:basic # Basic serverpnpm example:dataloaders # DataLoader examplepnpm example:subscriptions # Real-time subscriptionspnpm example:full # Full-featured exampleAvailable Examples
Section titled “Available Examples” Basic Server A minimal GraphQL server with queries, mutations, and GraphiQL. Perfect for getting started.
DataLoaders Solve the N+1 problem with Effect GQL's DataLoader integration for efficient batching.
Subscriptions Real-time GraphQL subscriptions using Effect Streams and WebSockets.
Full-Featured Production-ready example with services, auth, error handling, and modular architecture.
Example Structure
Section titled “Example Structure”Each example is a self-contained package in the examples/ directory:
examples/├── basic-server/ # Minimal getting-started example│ ├── package.json│ ├── tsconfig.json│ └── src/│ └── index.ts├── dataloaders/ # N+1 problem solution├── subscriptions/ # Real-time updates└── full-featured/ # Production patterns └── src/ ├── domain.ts # Effect Schema models ├── services.ts # Business logic services ├── loaders.ts # DataLoader definitions ├── schema.ts # GraphQL schema └── index.ts # Server entry pointQuick Comparison
Section titled “Quick Comparison”| Example | Queries | Mutations | Subscriptions | Services | DataLoaders |
|---|---|---|---|---|---|
| Basic Server | ✅ | ✅ | ❌ | ❌ | ❌ |
| DataLoaders | ✅ | ❌ | ❌ | ✅ | ✅ |
| Subscriptions | ✅ | ✅ | ✅ | ❌ | ❌ |
| Full-Featured | ✅ | ✅ | ❌ | ✅ | ✅ |