webiny-custom-graphql-api
하는 일
이 스킬은 Webiny 백엔드에 새 GraphQL 엔드포인트를 추가할 때 AI를 안내합니다. 플랫폼 서비스를 사용하는 맞춤 쿼리나 뮤테이션이 필요한 개발자를 위한 스킬입니다.
사용하는 경우
- ✓기본 쿼리나 뮤테이션 말고 맞춤 GraphQL 쿼리나 뮤테이션이 필요할 때.
- ✓리졸버가 신원이나 CMS 작업 같은 백엔드 서비스를 호출해야 할 때.
- ✓GraphQL 리졸버에 권한 검사가 필요한 경우.
스킬 링크
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/graphql-api/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“로그인한 사용자의 최근 주문 열 개를 반환하는 GraphQL 쿼리를 권한 검사와 함께 추가해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 타입 정의와 리졸버를 추가하는 스키마 팩토리를 구현하는 방법을 설명합니다. 각 리졸버는 컨테이너를 통해 의존성을 받고, 팩토리는 기본 내보내기로 내보냅니다.
기술 내용 (원본 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 fromcontext.container, not at schema build timeresolver: 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;
자주 묻는 질문
내보내기는 왜 기본 내보내기여야 하나요?
파일을 직접 등록할 때 이름 있는 내보내기는 빌드 실패를 일으킨다고 스킬이 설명합니다.
경로에 파일 확장자가 필요한가요?
네. 소스 경로에 .ts 확장자가 있어야 합니다.
리졸버가 백엔드 서비스를 쓸 수 있나요?
네. 신원, 테넌시, CMS 유스케이스 같은 서비스를 스키마에 주입하는 방법을 다룹니다.
상세 정보
작성자의 원본 설명
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
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
prd-to-plan
8.1k에이전트가 제품 요구사항 문서를 작고 끝까지 이어지는 조각들로 된 단계별 계획으로 바꿔 Markdown 파일로 저장하도록 돕습니다.
webiny-admin-architect
8.1k에이전트에게 Webiny 플랫폼의 관리자 화면을 비즈니스 로직 계층과 프레젠터 패턴으로 만드는 방법을 가르칩니다.
webiny-admin-permissions
8.1k에이전트에게 Webiny 관리자 화면에 권한 제어를 추가하는 법을 가르칩니다. 스키마에서 권한 양식을 자동 생성하고 표시 여부를 확인합니다.
webiny-form-model
8.1k에이전트에게 선언형 필드 빌더, 레이아웃, 검증, 조건부 규칙으로 Webiny 양식을 만드는 법을 가르칩니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.