@wyrly/graphql
v2.3.1
Published
Request-scoped dependency injection context for GraphQL and DataLoader patterns
Downloads
1,606
Maintainers
Readme
@wyrly/graphql
Request-scoped dependency injection for GraphQL and DataLoader-style resolver patterns without
reflect-metadata — one scope per request via createGraphQLDIContext.
Japanese: README.ja.md
Install
npm install @wyrly/graphql @wyrly/coreWorks with any GraphQL server that can pass Request / Response (or configure scope manually).
Requirements
- Everything required by
@wyrly/core
Quick start
import { createGraphQLDIContext } from "@wyrly/graphql";
import { createContainer } from "@wyrly/core";
const container = createContainer();
const context = async ({ req, res }: { req: Request; res: Response }) =>
createGraphQLDIContext(container, { request: req, response: res });
// resolvers use ctx.di.resolve(...)Documentation
Related packages
| Package | npm | Description |
| ---------------- | -------- | --------------------- |
| @wyrly/core | yes | Core DI |
| @wyrly/next | yes | Next.js App Router |
| @wyrly/express | yes | Express 5 middleware |
| @wyrly/hono | yes | Hono middleware |
| @wyrly/fastify | yes | Fastify 5 plugin |
| @wyrly/fresh | JSR only | Fresh 2.x |
| @wyrly/graphql | yes | This package |
| @wyrly/yoga | yes | GraphQL Yoga 5 plugin |
| @wyrly/apollo | yes | Apollo Server plugin |
License
Apache-2.0 — see LICENSE.
