generated from graphql/wg-template
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
As an opposite direction of composite schema, by creating subschemas, we can manage the schema size and have the ability to gradually reveal more parts of the schema to the model as it sees fit. This is inspired by the claude skill. Concrete example below:
1 Entrypoint SDL
Contains the directive and the root fields. Each field is annotated with the subschema(s) it requires. Types referenced here are defined in the subschemas.
# entrypoint.graphql
directive @require_graphql_subschema(names: [String!]!) on FIELD_DEFINITION
type Query {
# Task queries
task(id: ID!): Task
@require_graphql_subschema(names: ["TASK"])
tasks(first: Int, after: ID): [Task!]!
@require_graphql_subschema(names: ["TASK"])
# Calendar queries
calendarMeeting(id: ID!): CalendarMeeting
@require_graphql_subschema(names: ["CALENDAR"])
meetings(start: Int!, end: Int!): [CalendarMeeting!]!
@require_graphql_subschema(names: ["CALENDAR"])
}
- Task subschema SDL
Defines the Task domain types. No directive usage here—annotation is strictly at fields in the entrypoint or on field selections within objects (if you choose to gate nested fields too).
# task_subschema.graphql
type Task {
id: ID!
title: String!
priority: TaskPriority!
ownerId: ID
# If you need nested gating on object fields, you can apply the directive here too.
# comments: [TaskComment!]! @require_graphql_subschema(names: ["TASK"])
}
enum TaskPriority {
HIGH
MID
LOW
}
type TaskComment {
id: ID!
text: String!
createdAt: Int!
}
- Calendar subschema SDL
Defines calendar domain types. Again, no directive usage here unless you want to gate specific nested fields.
# calendar_subschema.graphql
type CalendarMeeting {
id: ID!
title: String!
startTime: Int!
endTime: Int!
attendees: [Employee!]! @require_graphql_subschema(names: ["EMPLOYEE"])
room: Room
}
type Room {
id: ID!
displayName: String!
}
Metadata
Metadata
Assignees
Labels
No labels