webiny-dependency-injection
यह क्या करती है
यह स्किल उस साझा पैटर्न को समझाती है जिससे हर Webiny extension अपनी सेवाएँ पाता है। यह किसी भी Webiny extension लिखने वाले डेवलपर के लिए है, जिसे समझना है कि उसका कोड अपनी dependencies कैसे पाता है।
कब इस्तेमाल करें
- ✓जब आप कोई Webiny extension लिख रहे हों और logger या identity context चाहिए।
- ✓जब आपके कोड से CMS create, update या delete ऑपरेशन कॉल करने हों।
- ✓जब आपको dependencies की सूची कैसे काम करती है, यह साफ़ न हो।
Skill का लिंक
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/dependency-injection/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी Webiny extension क्लास में logger और CMS एंट्री यूज़ केस को inject करना दिखाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
स्किल हर extension प्रकार के लिए वही चरण समझाती है: मेल खाने वाले interface के साथ एक क्लास लिखें, constructor में उसकी dependencies घोषित करें, और मेल खाने वाली factory और dependency list के साथ उसे export करें।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Dependency Injection Patterns
TL;DR
Every Webiny extension type uses the same DI pattern: define a class implementing *.Interface, declare dependencies in the constructor, and export via *.createImplementation({ implementation, dependencies }). The DI container automatically provides the required services, ensures type safety, and validates at compile time. This pattern is the connective tissue across all extension types -- API, Admin, CLI, and Infrastructure.
Working Context
This skill applies to both extension developers (working in extensions/) and core developers (working in packages/). The DI pattern is universal — only the import paths differ.
Extensions (extensions/) |
Core (packages/) |
|
|---|---|---|
createAbstraction |
from "webiny/api" or from "webiny/admin" |
from "@webiny/feature/api" or from "@webiny/feature/admin" |
createFeature |
from "webiny/api" or from "webiny/admin" |
from "@webiny/feature/api" or from "@webiny/feature/admin" |
| Factory imports | from "webiny/api/graphql", from "webiny/api/cms/model", etc. |
Direct package paths: from "@webiny/handler-graphql/...", from "@webiny/api-headless-cms/..." |
| Catalog paths | Use the Import: path |
Use the Source: path |
Detect which context you're in by checking the file path: extensions/ → extension mode, packages/ → core mode. The dependencies array, constructor injection, scoping rules, and all other patterns are identical in both contexts.
The Universal Pattern
import { SomeFactory } from "webiny/some/path";
import { Logger, BuildParams } from "webiny/api";
class MyImplementation implements SomeFactory.Interface {
constructor(
private logger: Logger.Interface,
private buildParams: BuildParams.Interface
) {}
execute(/* factory-specific params */) {
this.logger.info("Doing something...");
// buildParams.get() returns T | null — always account for null.
const value = this.buildParams.get<string>("MY_PARAM");
}
}
export default SomeFactory.createImplementation({
implementation: MyImplementation,
dependencies: [Logger, BuildParams]
});
Key rules:
- One class per file -- each extension file exports a single implementation.
- Constructor injection -- dependencies are received as constructor parameters, in the same order as the
dependenciesarray. - Dependencies array -- must exactly match the constructor parameter order and types.
- Interface types -- always type constructor params as
Feature.Interface.
Where This Pattern Appears
| Extension Type | Factory | Import Path |
|---|---|---|
| Content Models | ModelFactory |
"webiny/api/cms/model" |
| GraphQL Schemas | GraphQLSchemaFactory |
"webiny/api/graphql" |
| API Keys | ApiKeyFactory |
"webiny/api/security" |
| CLI Commands | CliCommandFactory |
"webiny/cli/command" |
| Pulumi Handlers | CorePulumi |
"webiny/infra/core" |
Event handlers use the same
createImplementationpattern but are not injectable dependencies.
Examples Across Extension Types
API Extension (GraphQL Schema with DI)
GraphQL schemas use the builder pattern. The execute method receives a builder and uses addTypeDefs and addResolver to define the schema. Resolver-level DI is declared per-resolver via dependencies in addResolver, resolved at request time from the request-scoped container.
import { GraphQLSchemaFactory } from "webiny/api/graphql";
import { IdentityContext } from "webiny/api/security";
class WhoAmISchema implements GraphQLSchemaFactory.Interface {
async execute(
builder: GraphQLSchemaFactory.SchemaBuilder
): Promise<GraphQLSchemaFactory.SchemaBuilder> {
builder.addTypeDefs(/* Gr
अक्सर पूछे जाने वाले सवाल
इस पैटर्न के हिस्से कौन से हैं?
interface लागू करने वाली एक क्लास, constructor dependencies, और dependencies list के साथ export की गई factory।
क्या यह सभी extension प्रकारों पर काम करता है?
हाँ। स्किल के अनुसार यह API, admin, CLI और infrastructure extensions पर लागू होता है।
कौन सी सेवाएँ inject हो सकती हैं?
उदाहरण के लिए logger, build parameters, identity context और CMS entry यूज़ केस।
जानकारी
लेखक का मूल विवरण
The universal createImplementation DI pattern and all injectable services. Use this skill when the developer is writing any Webiny extension and needs to understand dependency injection, constructor injection, how to access Logger/BuildParams/IdentityContext, how to inject CMS use-cases (list/get/create/update/delete entries), or how the dependencies array works. This is the connective tissue across all extension types -- API, Admin, CLI, and Infrastructure.
repo: webiny/webiny-js
लोकप्रियता
- GitHub स्टार
- 8.1k
- रैंकिंग में स्थान
- #12599
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
prd-to-plan
8.1kयह आपके एजेंट को प्रोडक्ट आवश्यकताओं के दस्तावेज़ को छोटे, एंड-टू-एंड स्लाइस की चरणबद्ध योजना में बदलने में मदद करती है, जो Markdown फ़ाइल में सहेजी जाती है।
webiny-admin-architect
8.1kयह आपके एजेंट को Webiny प्लेटफ़ॉर्म के लिए एडमिन स्क्रीन बनाना सिखाती है, उसकी बिज़नेस लॉजिक परतों और presenter पैटर्न का उपयोग करके।
webiny-admin-permissions
8.1kयह आपके एजेंट को Webiny एडमिन स्क्रीन में अनुमति नियंत्रण जोड़ना सिखाती है, जिसमें अपने-आप बनने वाले अनुमति फ़ॉर्म और दिखाने-छिपाने की जाँच शामिल हैं।
webiny-form-model
8.1kयह आपके एजेंट को Webiny में declarative field builder, layouts, validation और शर्त वाले नियमों से फ़ॉर्म बनाना सिखाती है।
मिलती-जुलती skills
api-connector-builder
280kयह आपके एजेंट को मौजूदा pattern के हिसाब से नए API connections बनाने देता है। जब बिना कोई नया तरीका बनाए एक और integration जोड़ना हो, तब इसका इस्तेमाल करें।
api-design
280kयह आपके एजेंट को best practices के हिसाब से REST APIs डिज़ाइन करने में मदद करता है। यह तय करने में काम आता है कि APIs आपस में कैसे बात करें, errors कैसे दिखें, और data को कैसे व्यवस्थित करें।
backend-patterns
280kआपके एजेंट को server-side architecture patterns और database optimization में मदद करता है। server पर चलने वाला code बनाने या review करने के लिए उपयोगी है।