मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)8.1k · #12587

webiny-custom-graphql-api

यह क्या करती है

यह स्किल आपके AI को Webiny बैकएंड में नए GraphQL endpoints जोड़ते समय मार्गदर्शन देती है। यह उन डेवलपर्स के लिए है जिन्हें बिल्ट-इन से आगे कस्टम queries या mutations चाहिए, जो प्लेटफ़ॉर्म की सेवाएँ इस्तेमाल करें।

कब इस्तेमाल करें

  • ✓जब आपको बिल्ट-इन से आगे कोई कस्टम GraphQL query या mutation चाहिए।
  • ✓जब किसी resolver को identity या CMS ऑपरेशन जैसी बैकएंड सेवाएँ कॉल करनी हों।
  • ✓जब किसी GraphQL resolver को authorization जाँच चाहिए।

Skill का लिंक

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/graphql-api/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/graphql-api/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“एक GraphQL query जोड़िए, जो लॉगिन किए उपयोगकर्ता के दस सबसे नए ऑर्डर लौटाए, और उसमें अनुमति जाँच हो।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

स्किल दिखाती है कि एक schema factory कैसे लागू करें, जो type definitions और resolvers जोड़े। हर resolver अपनी dependencies container से पाता है, और factory को default export किया जाता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Custom GraphQL API

TL;DR

Add custom GraphQL queries and mutations using GraphQLSchemaFactory. Implement GraphQLSchemaFactory.Interface, use the schema builder to add type definitions and resolvers (with per-resolver DI), and export with GraphQLSchemaFactory.createImplementation(). Register as <Api.Extension>.

YOU MUST include the full file path with the .ts extension in every src prop. For example, use src={"/extensions/MySchema.ts"}, NOT src={"/extensions/MySchema"}. Omitting the file extension will cause a build failure.

YOU MUST use export default for the createImplementation() call when the file is targeted directly by an Extension src prop. Using a named export (export const Foo = SomeFactory.createImplementation(...)) will cause a build failure. Named exports are only valid inside files registered via createFeature.

The GraphQLSchemaFactory Pattern

The execute method receives a schema builder and returns it after adding type defs and resolvers.

// extensions/mySchema/MyGraphQLSchema.ts
import { GraphQLSchemaFactory } from "webiny/api/graphql";

class MySchema implements GraphQLSchemaFactory.Interface {
  async execute(
    builder: GraphQLSchemaFactory.SchemaBuilder
  ): Promise<GraphQLSchemaFactory.SchemaBuilder> {
    builder.addTypeDefs(/* GraphQL */ `
      extend type Query {
        hello: String!
      }
    `);

    builder.addResolver({
      path: "Query.hello",
      resolver: () => {
        return () => "Hello, World!";
      }
    });

    return builder;
  }
}

export default GraphQLSchemaFactory.createImplementation({
  implementation: MySchema,
  dependencies: []
});

Register as an extension:

// extensions/mySchema/Extension.tsx
import React from "react";
import { Api } from "webiny/extensions";

export const MySchema = () => {
  return <Api.Extension src={"@/extensions/mySchema/MyGraphQLSchema.ts"} />;
};

Schema Builder API Reference

Method Description
builder.addTypeDefs(typeDefs: string) Add GraphQL type definitions (use extend type Query/Mutation to add to existing root types)
builder.addResolver<TArgs>(config) Add a resolver with optional per-resolver DI dependencies

addResolver Config

builder.addResolver<TArgs>({
    path: "TypeName.fieldName",         // dot-separated path
    dependencies: [SomeAbstraction],    // optional: DI tokens resolved at request time
    resolver: (dep1, dep2, ...) => {    // factory: receives resolved deps
        return ({ parent, args, context, info }) => {
            // actual resolver logic
            return result;
        };
    }
});

Key points:

  • path: Dot-separated GraphQL type path, e.g. "Query.hello", "Mutation.createOrder", "OrderMutation.create"
  • dependencies: Array of DI abstraction tokens. Resolved per-request from context.container, not at schema build time
  • resolver: A factory function that receives resolved dependencies and returns the actual resolver function
  • Resolver params: The inner function receives { parent, args, context, info } (named object, not positional)

Per-Resolver Dependency Injection

Dependencies in addResolver are resolved at request time from the request-scoped container. This is different from class-level constructor DI — it gives each resolver access to request-scoped services like identity and tenant context.

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(/* GraphQL */ `
      extend type Query {
        whoAmI: String
      }
    `);

    builder.addResolver({
      path: "Query.whoAmI",
      dependencies: [IdentityContext],
      resolver: (identityContext: IdentityContext.Interface) => {
        return () => {
          const identity = identityContext.getIdentity();
          return `Hello, ${identity.displayName}!`;
        };
      }
    });

    return builder;
अक्सर पूछे जाने वाले सवाल

export default ही क्यों होना चाहिए?

स्किल कहती है कि named export होने पर फ़ाइल सीधे रजिस्टर करने पर बिल्ड फ़ेल हो जाता है।

क्या पाथ में फ़ाइल एक्सटेंशन चाहिए?

हाँ। source पाथ में .ts एक्सटेंशन होना चाहिए।

क्या resolvers बैकएंड सेवाएँ इस्तेमाल कर सकते हैं?

हाँ। स्किल identity, tenancy और CMS use cases जैसी सेवाओं को schema में inject करना कवर करती है।

जानकारी

लेखक का मूल विवरण

Adding custom GraphQL queries and mutations using GraphQLSchemaFactory. Use this skill when the developer wants to add custom GraphQL endpoints, create custom queries or mutations, add business logic to the API layer, build custom resolvers, inject backend services (identity, tenancy, CMS use-cases) into their GraphQL schema, add authorization checks to resolvers, or build dynamic GraphQL inputs from CMS models. Covers the full pattern from simple queries to complex resolvers with dependency injection and permission transformers.

repo: webiny/webiny-js

लोकप्रियता

GitHub स्टार
8.1k
रैंकिंग में स्थान
#12587
लाइसेंस
—
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

prd-to-plan

8.1k

यह आपके एजेंट को प्रोडक्ट आवश्यकताओं के दस्तावेज़ को छोटे, एंड-टू-एंड स्लाइस की चरणबद्ध योजना में बदलने में मदद करती है, जो Markdown फ़ाइल में सहेजी जाती है।

प्रोडक्टिविटीटास्क और प्रोजेक्ट

webiny-admin-architect

8.1k

यह आपके एजेंट को Webiny प्लेटफ़ॉर्म के लिए एडमिन स्क्रीन बनाना सिखाती है, उसकी बिज़नेस लॉजिक परतों और presenter पैटर्न का उपयोग करके।

कोडिंगवेबसाइट और UI (frontend)

webiny-admin-permissions

8.1k

यह आपके एजेंट को Webiny एडमिन स्क्रीन में अनुमति नियंत्रण जोड़ना सिखाती है, जिसमें अपने-आप बनने वाले अनुमति फ़ॉर्म और दिखाने-छिपाने की जाँच शामिल हैं।

कोडिंगवेबसाइट और UI (frontend)

webiny-form-model

8.1k

यह आपके एजेंट को Webiny में declarative field builder, layouts, validation और शर्त वाले नियमों से फ़ॉर्म बनाना सिखाती है।

कोडिंगवेबसाइट और UI (frontend)

मिलती-जुलती skills