opencode-metis 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -0
- package/dist/cli.cjs +63 -0
- package/dist/mcp-server.cjs +51 -0
- package/dist/plugin.cjs +4 -0
- package/dist/worker.cjs +224 -0
- package/opencode/agent/the-analyst/feature-prioritization.md +66 -0
- package/opencode/agent/the-analyst/market-research.md +77 -0
- package/opencode/agent/the-analyst/project-coordination.md +81 -0
- package/opencode/agent/the-analyst/requirements-analysis.md +77 -0
- package/opencode/agent/the-architect/compatibility-review.md +138 -0
- package/opencode/agent/the-architect/complexity-review.md +137 -0
- package/opencode/agent/the-architect/quality-review.md +67 -0
- package/opencode/agent/the-architect/security-review.md +127 -0
- package/opencode/agent/the-architect/system-architecture.md +119 -0
- package/opencode/agent/the-architect/system-documentation.md +83 -0
- package/opencode/agent/the-architect/technology-research.md +85 -0
- package/opencode/agent/the-chief.md +79 -0
- package/opencode/agent/the-designer/accessibility-implementation.md +101 -0
- package/opencode/agent/the-designer/design-foundation.md +74 -0
- package/opencode/agent/the-designer/interaction-architecture.md +75 -0
- package/opencode/agent/the-designer/user-research.md +70 -0
- package/opencode/agent/the-meta-agent.md +155 -0
- package/opencode/agent/the-platform-engineer/ci-cd-pipelines.md +109 -0
- package/opencode/agent/the-platform-engineer/containerization.md +106 -0
- package/opencode/agent/the-platform-engineer/data-architecture.md +81 -0
- package/opencode/agent/the-platform-engineer/dependency-review.md +144 -0
- package/opencode/agent/the-platform-engineer/deployment-automation.md +81 -0
- package/opencode/agent/the-platform-engineer/infrastructure-as-code.md +107 -0
- package/opencode/agent/the-platform-engineer/performance-tuning.md +82 -0
- package/opencode/agent/the-platform-engineer/pipeline-engineering.md +81 -0
- package/opencode/agent/the-platform-engineer/production-monitoring.md +105 -0
- package/opencode/agent/the-qa-engineer/exploratory-testing.md +66 -0
- package/opencode/agent/the-qa-engineer/performance-testing.md +81 -0
- package/opencode/agent/the-qa-engineer/quality-assurance.md +77 -0
- package/opencode/agent/the-qa-engineer/test-execution.md +66 -0
- package/opencode/agent/the-software-engineer/api-development.md +78 -0
- package/opencode/agent/the-software-engineer/component-development.md +79 -0
- package/opencode/agent/the-software-engineer/concurrency-review.md +141 -0
- package/opencode/agent/the-software-engineer/domain-modeling.md +66 -0
- package/opencode/agent/the-software-engineer/performance-optimization.md +113 -0
- package/opencode/command/analyze.md +149 -0
- package/opencode/command/constitution.md +178 -0
- package/opencode/command/debug.md +194 -0
- package/opencode/command/document.md +178 -0
- package/opencode/command/implement.md +225 -0
- package/opencode/command/refactor.md +207 -0
- package/opencode/command/review.md +229 -0
- package/opencode/command/simplify.md +267 -0
- package/opencode/command/specify.md +191 -0
- package/opencode/command/validate.md +224 -0
- package/opencode/skill/accessibility-design/SKILL.md +566 -0
- package/opencode/skill/accessibility-design/checklists/wcag-checklist.md +435 -0
- package/opencode/skill/agent-coordination/SKILL.md +224 -0
- package/opencode/skill/api-contract-design/SKILL.md +550 -0
- package/opencode/skill/api-contract-design/templates/graphql-schema-template.md +818 -0
- package/opencode/skill/api-contract-design/templates/rest-api-template.md +417 -0
- package/opencode/skill/architecture-design/SKILL.md +160 -0
- package/opencode/skill/architecture-design/examples/architecture-examples.md +170 -0
- package/opencode/skill/architecture-design/template.md +749 -0
- package/opencode/skill/architecture-design/validation.md +99 -0
- package/opencode/skill/architecture-selection/SKILL.md +522 -0
- package/opencode/skill/architecture-selection/examples/adrs/001-example-adr.md +71 -0
- package/opencode/skill/architecture-selection/examples/architecture-patterns.md +239 -0
- package/opencode/skill/bug-diagnosis/SKILL.md +235 -0
- package/opencode/skill/code-quality-review/SKILL.md +337 -0
- package/opencode/skill/code-quality-review/examples/anti-patterns.md +629 -0
- package/opencode/skill/code-quality-review/reference.md +322 -0
- package/opencode/skill/code-review/SKILL.md +363 -0
- package/opencode/skill/code-review/reference.md +450 -0
- package/opencode/skill/codebase-analysis/SKILL.md +139 -0
- package/opencode/skill/codebase-navigation/SKILL.md +227 -0
- package/opencode/skill/codebase-navigation/examples/exploration-patterns.md +263 -0
- package/opencode/skill/coding-conventions/SKILL.md +178 -0
- package/opencode/skill/coding-conventions/checklists/accessibility-checklist.md +176 -0
- package/opencode/skill/coding-conventions/checklists/performance-checklist.md +154 -0
- package/opencode/skill/coding-conventions/checklists/security-checklist.md +127 -0
- package/opencode/skill/constitution-validation/SKILL.md +315 -0
- package/opencode/skill/constitution-validation/examples/CONSTITUTION.md +202 -0
- package/opencode/skill/constitution-validation/reference/rule-patterns.md +328 -0
- package/opencode/skill/constitution-validation/template.md +115 -0
- package/opencode/skill/context-preservation/SKILL.md +445 -0
- package/opencode/skill/data-modeling/SKILL.md +385 -0
- package/opencode/skill/data-modeling/templates/schema-design-template.md +268 -0
- package/opencode/skill/deployment-pipeline-design/SKILL.md +579 -0
- package/opencode/skill/deployment-pipeline-design/templates/pipeline-template.md +633 -0
- package/opencode/skill/documentation-extraction/SKILL.md +259 -0
- package/opencode/skill/documentation-sync/SKILL.md +431 -0
- package/opencode/skill/domain-driven-design/SKILL.md +509 -0
- package/opencode/skill/domain-driven-design/examples/ddd-patterns.md +688 -0
- package/opencode/skill/domain-driven-design/reference.md +465 -0
- package/opencode/skill/drift-detection/SKILL.md +383 -0
- package/opencode/skill/drift-detection/reference.md +340 -0
- package/opencode/skill/error-recovery/SKILL.md +162 -0
- package/opencode/skill/error-recovery/examples/error-patterns.md +484 -0
- package/opencode/skill/feature-prioritization/SKILL.md +419 -0
- package/opencode/skill/feature-prioritization/examples/rice-template.md +139 -0
- package/opencode/skill/feature-prioritization/reference.md +256 -0
- package/opencode/skill/git-workflow/SKILL.md +453 -0
- package/opencode/skill/implementation-planning/SKILL.md +215 -0
- package/opencode/skill/implementation-planning/examples/phase-examples.md +217 -0
- package/opencode/skill/implementation-planning/template.md +220 -0
- package/opencode/skill/implementation-planning/validation.md +88 -0
- package/opencode/skill/implementation-verification/SKILL.md +272 -0
- package/opencode/skill/knowledge-capture/SKILL.md +265 -0
- package/opencode/skill/knowledge-capture/reference/knowledge-capture.md +402 -0
- package/opencode/skill/knowledge-capture/reference.md +444 -0
- package/opencode/skill/knowledge-capture/templates/domain-template.md +325 -0
- package/opencode/skill/knowledge-capture/templates/interface-template.md +255 -0
- package/opencode/skill/knowledge-capture/templates/pattern-template.md +144 -0
- package/opencode/skill/observability-design/SKILL.md +291 -0
- package/opencode/skill/observability-design/references/monitoring-patterns.md +461 -0
- package/opencode/skill/pattern-detection/SKILL.md +171 -0
- package/opencode/skill/pattern-detection/examples/common-patterns.md +359 -0
- package/opencode/skill/performance-analysis/SKILL.md +266 -0
- package/opencode/skill/performance-analysis/references/profiling-tools.md +499 -0
- package/opencode/skill/requirements-analysis/SKILL.md +139 -0
- package/opencode/skill/requirements-analysis/examples/good-prd.md +66 -0
- package/opencode/skill/requirements-analysis/template.md +177 -0
- package/opencode/skill/requirements-analysis/validation.md +69 -0
- package/opencode/skill/requirements-elicitation/SKILL.md +518 -0
- package/opencode/skill/requirements-elicitation/examples/interview-questions.md +226 -0
- package/opencode/skill/requirements-elicitation/examples/user-stories.md +414 -0
- package/opencode/skill/safe-refactoring/SKILL.md +312 -0
- package/opencode/skill/safe-refactoring/reference/code-smells.md +347 -0
- package/opencode/skill/security-assessment/SKILL.md +421 -0
- package/opencode/skill/security-assessment/checklists/security-review-checklist.md +285 -0
- package/opencode/skill/specification-management/SKILL.md +143 -0
- package/opencode/skill/specification-management/readme-template.md +32 -0
- package/opencode/skill/specification-management/reference.md +115 -0
- package/opencode/skill/specification-management/spec.py +229 -0
- package/opencode/skill/specification-validation/SKILL.md +397 -0
- package/opencode/skill/specification-validation/reference/3cs-framework.md +306 -0
- package/opencode/skill/specification-validation/reference/ambiguity-detection.md +132 -0
- package/opencode/skill/specification-validation/reference/constitution-validation.md +301 -0
- package/opencode/skill/specification-validation/reference/drift-detection.md +383 -0
- package/opencode/skill/task-delegation/SKILL.md +607 -0
- package/opencode/skill/task-delegation/examples/file-coordination.md +495 -0
- package/opencode/skill/task-delegation/examples/parallel-research.md +337 -0
- package/opencode/skill/task-delegation/examples/sequential-build.md +504 -0
- package/opencode/skill/task-delegation/reference.md +825 -0
- package/opencode/skill/tech-stack-detection/SKILL.md +89 -0
- package/opencode/skill/tech-stack-detection/references/framework-signatures.md +598 -0
- package/opencode/skill/technical-writing/SKILL.md +190 -0
- package/opencode/skill/technical-writing/templates/adr-template.md +205 -0
- package/opencode/skill/technical-writing/templates/system-doc-template.md +380 -0
- package/opencode/skill/test-design/SKILL.md +464 -0
- package/opencode/skill/test-design/examples/test-pyramid.md +724 -0
- package/opencode/skill/testing/SKILL.md +213 -0
- package/opencode/skill/testing/examples/test-pyramid.md +724 -0
- package/opencode/skill/user-insight-synthesis/SKILL.md +576 -0
- package/opencode/skill/user-insight-synthesis/templates/research-plan-template.md +217 -0
- package/opencode/skill/user-research/SKILL.md +508 -0
- package/opencode/skill/user-research/examples/interview-questions.md +265 -0
- package/opencode/skill/user-research/examples/personas.md +267 -0
- package/opencode/skill/vibe-security/SKILL.md +654 -0
- package/package.json +45 -0
|
@@ -0,0 +1,818 @@
|
|
|
1
|
+
# Template: GraphQL Schema Design
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Use this template to design GraphQL schemas with consistent patterns for types, queries, mutations, and subscriptions. Follows Relay-style connections for pagination and input/payload patterns for mutations.
|
|
6
|
+
|
|
7
|
+
## Template
|
|
8
|
+
|
|
9
|
+
```graphql
|
|
10
|
+
# =============================================================================
|
|
11
|
+
# [API Name] GraphQL Schema
|
|
12
|
+
# =============================================================================
|
|
13
|
+
#
|
|
14
|
+
# Description: [Brief description of the API's purpose]
|
|
15
|
+
# Version: 1.0.0
|
|
16
|
+
# Last Updated: [Date]
|
|
17
|
+
#
|
|
18
|
+
# Conventions:
|
|
19
|
+
# - Types use PascalCase
|
|
20
|
+
# - Fields use camelCase
|
|
21
|
+
# - Enums use SCREAMING_SNAKE_CASE
|
|
22
|
+
# - Connections follow Relay specification
|
|
23
|
+
# - Mutations use Input/Payload pattern
|
|
24
|
+
# =============================================================================
|
|
25
|
+
|
|
26
|
+
# -----------------------------------------------------------------------------
|
|
27
|
+
# SCALARS
|
|
28
|
+
# -----------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
A datetime string in ISO 8601 format: YYYY-MM-DDTHH:mm:ss.sssZ
|
|
32
|
+
"""
|
|
33
|
+
scalar DateTime
|
|
34
|
+
|
|
35
|
+
"""
|
|
36
|
+
A UUID string following RFC 4122
|
|
37
|
+
"""
|
|
38
|
+
scalar UUID
|
|
39
|
+
|
|
40
|
+
"""
|
|
41
|
+
Arbitrary JSON object for flexible data
|
|
42
|
+
"""
|
|
43
|
+
scalar JSON
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
A URL string
|
|
47
|
+
"""
|
|
48
|
+
scalar URL
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
An email address string
|
|
52
|
+
"""
|
|
53
|
+
scalar Email
|
|
54
|
+
|
|
55
|
+
# -----------------------------------------------------------------------------
|
|
56
|
+
# ENUMS
|
|
57
|
+
# -----------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
"""
|
|
60
|
+
Sort direction for ordered results
|
|
61
|
+
"""
|
|
62
|
+
enum SortDirection {
|
|
63
|
+
ASC
|
|
64
|
+
DESC
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
"""
|
|
68
|
+
Status values for [Resource]
|
|
69
|
+
"""
|
|
70
|
+
enum [Resource]Status {
|
|
71
|
+
DRAFT
|
|
72
|
+
ACTIVE
|
|
73
|
+
ARCHIVED
|
|
74
|
+
DELETED
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# -----------------------------------------------------------------------------
|
|
78
|
+
# INTERFACES
|
|
79
|
+
# -----------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
Node interface for Relay-compliant object identification
|
|
83
|
+
"""
|
|
84
|
+
interface Node {
|
|
85
|
+
"""
|
|
86
|
+
Global unique identifier
|
|
87
|
+
"""
|
|
88
|
+
id: ID!
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
"""
|
|
92
|
+
Timestamped interface for entities with audit fields
|
|
93
|
+
"""
|
|
94
|
+
interface Timestamped {
|
|
95
|
+
"""
|
|
96
|
+
When the entity was created
|
|
97
|
+
"""
|
|
98
|
+
createdAt: DateTime!
|
|
99
|
+
|
|
100
|
+
"""
|
|
101
|
+
When the entity was last updated
|
|
102
|
+
"""
|
|
103
|
+
updatedAt: DateTime!
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# -----------------------------------------------------------------------------
|
|
107
|
+
# TYPES: Core Entities
|
|
108
|
+
# -----------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
[Description of what this type represents]
|
|
112
|
+
"""
|
|
113
|
+
type [Resource] implements Node & Timestamped {
|
|
114
|
+
"""
|
|
115
|
+
Unique identifier for the [resource]
|
|
116
|
+
"""
|
|
117
|
+
id: ID!
|
|
118
|
+
|
|
119
|
+
"""
|
|
120
|
+
[Description of field]
|
|
121
|
+
"""
|
|
122
|
+
[field]: [Type]!
|
|
123
|
+
|
|
124
|
+
"""
|
|
125
|
+
[Description of optional field]
|
|
126
|
+
"""
|
|
127
|
+
[optionalField]: [Type]
|
|
128
|
+
|
|
129
|
+
"""
|
|
130
|
+
Current status of the [resource]
|
|
131
|
+
"""
|
|
132
|
+
status: [Resource]Status!
|
|
133
|
+
|
|
134
|
+
"""
|
|
135
|
+
When the [resource] was created
|
|
136
|
+
"""
|
|
137
|
+
createdAt: DateTime!
|
|
138
|
+
|
|
139
|
+
"""
|
|
140
|
+
When the [resource] was last updated
|
|
141
|
+
"""
|
|
142
|
+
updatedAt: DateTime!
|
|
143
|
+
|
|
144
|
+
# ---------------------------------------------------------------------------
|
|
145
|
+
# Relationships
|
|
146
|
+
# ---------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
"""
|
|
149
|
+
The [related entity] this [resource] belongs to
|
|
150
|
+
"""
|
|
151
|
+
[parent]: [ParentType]!
|
|
152
|
+
|
|
153
|
+
"""
|
|
154
|
+
[Children] associated with this [resource]
|
|
155
|
+
"""
|
|
156
|
+
[children](
|
|
157
|
+
first: Int
|
|
158
|
+
after: String
|
|
159
|
+
last: Int
|
|
160
|
+
before: String
|
|
161
|
+
filter: [Child]Filter
|
|
162
|
+
orderBy: [Child]OrderBy
|
|
163
|
+
): [Child]Connection!
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
# -----------------------------------------------------------------------------
|
|
167
|
+
# TYPES: Connections (Relay-style Pagination)
|
|
168
|
+
# -----------------------------------------------------------------------------
|
|
169
|
+
|
|
170
|
+
"""
|
|
171
|
+
A connection to a list of [Resource] items
|
|
172
|
+
"""
|
|
173
|
+
type [Resource]Connection {
|
|
174
|
+
"""
|
|
175
|
+
A list of edges
|
|
176
|
+
"""
|
|
177
|
+
edges: [[Resource]Edge!]!
|
|
178
|
+
|
|
179
|
+
"""
|
|
180
|
+
Information to aid in pagination
|
|
181
|
+
"""
|
|
182
|
+
pageInfo: PageInfo!
|
|
183
|
+
|
|
184
|
+
"""
|
|
185
|
+
Total number of items in the connection
|
|
186
|
+
"""
|
|
187
|
+
totalCount: Int!
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
"""
|
|
191
|
+
An edge in a [Resource] connection
|
|
192
|
+
"""
|
|
193
|
+
type [Resource]Edge {
|
|
194
|
+
"""
|
|
195
|
+
The item at the end of the edge
|
|
196
|
+
"""
|
|
197
|
+
node: [Resource]!
|
|
198
|
+
|
|
199
|
+
"""
|
|
200
|
+
A cursor for use in pagination
|
|
201
|
+
"""
|
|
202
|
+
cursor: String!
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
"""
|
|
206
|
+
Information about pagination in a connection
|
|
207
|
+
"""
|
|
208
|
+
type PageInfo {
|
|
209
|
+
"""
|
|
210
|
+
When paginating forwards, are there more items?
|
|
211
|
+
"""
|
|
212
|
+
hasNextPage: Boolean!
|
|
213
|
+
|
|
214
|
+
"""
|
|
215
|
+
When paginating backwards, are there more items?
|
|
216
|
+
"""
|
|
217
|
+
hasPreviousPage: Boolean!
|
|
218
|
+
|
|
219
|
+
"""
|
|
220
|
+
When paginating backwards, the cursor to continue
|
|
221
|
+
"""
|
|
222
|
+
startCursor: String
|
|
223
|
+
|
|
224
|
+
"""
|
|
225
|
+
When paginating forwards, the cursor to continue
|
|
226
|
+
"""
|
|
227
|
+
endCursor: String
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
# -----------------------------------------------------------------------------
|
|
231
|
+
# INPUTS: Filtering and Ordering
|
|
232
|
+
# -----------------------------------------------------------------------------
|
|
233
|
+
|
|
234
|
+
"""
|
|
235
|
+
Filter criteria for [Resource] queries
|
|
236
|
+
"""
|
|
237
|
+
input [Resource]Filter {
|
|
238
|
+
"""
|
|
239
|
+
Filter by status
|
|
240
|
+
"""
|
|
241
|
+
status: [Resource]Status
|
|
242
|
+
|
|
243
|
+
"""
|
|
244
|
+
Filter by [parent] ID
|
|
245
|
+
"""
|
|
246
|
+
[parent]Id: ID
|
|
247
|
+
|
|
248
|
+
"""
|
|
249
|
+
Filter by creation date range
|
|
250
|
+
"""
|
|
251
|
+
createdAfter: DateTime
|
|
252
|
+
|
|
253
|
+
"""
|
|
254
|
+
Filter by creation date range
|
|
255
|
+
"""
|
|
256
|
+
createdBefore: DateTime
|
|
257
|
+
|
|
258
|
+
"""
|
|
259
|
+
Full-text search query
|
|
260
|
+
"""
|
|
261
|
+
searchQuery: String
|
|
262
|
+
|
|
263
|
+
"""
|
|
264
|
+
Combine multiple filters with AND
|
|
265
|
+
"""
|
|
266
|
+
AND: [[Resource]Filter!]
|
|
267
|
+
|
|
268
|
+
"""
|
|
269
|
+
Combine multiple filters with OR
|
|
270
|
+
"""
|
|
271
|
+
OR: [[Resource]Filter!]
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
"""
|
|
275
|
+
Ordering options for [Resource] queries
|
|
276
|
+
"""
|
|
277
|
+
input [Resource]OrderBy {
|
|
278
|
+
"""
|
|
279
|
+
Field to order by
|
|
280
|
+
"""
|
|
281
|
+
field: [Resource]OrderField!
|
|
282
|
+
|
|
283
|
+
"""
|
|
284
|
+
Sort direction
|
|
285
|
+
"""
|
|
286
|
+
direction: SortDirection!
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
"""
|
|
290
|
+
Fields available for ordering [Resource] queries
|
|
291
|
+
"""
|
|
292
|
+
enum [Resource]OrderField {
|
|
293
|
+
CREATED_AT
|
|
294
|
+
UPDATED_AT
|
|
295
|
+
[FIELD_NAME]
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
# -----------------------------------------------------------------------------
|
|
299
|
+
# QUERIES
|
|
300
|
+
# -----------------------------------------------------------------------------
|
|
301
|
+
|
|
302
|
+
type Query {
|
|
303
|
+
# ---------------------------------------------------------------------------
|
|
304
|
+
# Node Query (Relay requirement)
|
|
305
|
+
# ---------------------------------------------------------------------------
|
|
306
|
+
|
|
307
|
+
"""
|
|
308
|
+
Fetch any node by its global ID
|
|
309
|
+
"""
|
|
310
|
+
node(
|
|
311
|
+
"""
|
|
312
|
+
The global ID of the node
|
|
313
|
+
"""
|
|
314
|
+
id: ID!
|
|
315
|
+
): Node
|
|
316
|
+
|
|
317
|
+
"""
|
|
318
|
+
Fetch multiple nodes by their global IDs
|
|
319
|
+
"""
|
|
320
|
+
nodes(
|
|
321
|
+
"""
|
|
322
|
+
The global IDs of the nodes
|
|
323
|
+
"""
|
|
324
|
+
ids: [ID!]!
|
|
325
|
+
): [Node]!
|
|
326
|
+
|
|
327
|
+
# ---------------------------------------------------------------------------
|
|
328
|
+
# Viewer Query (Current User Context)
|
|
329
|
+
# ---------------------------------------------------------------------------
|
|
330
|
+
|
|
331
|
+
"""
|
|
332
|
+
The currently authenticated user
|
|
333
|
+
"""
|
|
334
|
+
viewer: User
|
|
335
|
+
|
|
336
|
+
# ---------------------------------------------------------------------------
|
|
337
|
+
# [Resource] Queries
|
|
338
|
+
# ---------------------------------------------------------------------------
|
|
339
|
+
|
|
340
|
+
"""
|
|
341
|
+
Fetch a single [resource] by ID
|
|
342
|
+
"""
|
|
343
|
+
[resource](
|
|
344
|
+
"""
|
|
345
|
+
The unique identifier of the [resource]
|
|
346
|
+
"""
|
|
347
|
+
id: ID!
|
|
348
|
+
): [Resource]
|
|
349
|
+
|
|
350
|
+
"""
|
|
351
|
+
Fetch a paginated list of [resources]
|
|
352
|
+
"""
|
|
353
|
+
[resources](
|
|
354
|
+
"""
|
|
355
|
+
Number of items to fetch (forward pagination)
|
|
356
|
+
"""
|
|
357
|
+
first: Int
|
|
358
|
+
|
|
359
|
+
"""
|
|
360
|
+
Cursor to start after (forward pagination)
|
|
361
|
+
"""
|
|
362
|
+
after: String
|
|
363
|
+
|
|
364
|
+
"""
|
|
365
|
+
Number of items to fetch (backward pagination)
|
|
366
|
+
"""
|
|
367
|
+
last: Int
|
|
368
|
+
|
|
369
|
+
"""
|
|
370
|
+
Cursor to start before (backward pagination)
|
|
371
|
+
"""
|
|
372
|
+
before: String
|
|
373
|
+
|
|
374
|
+
"""
|
|
375
|
+
Filter criteria
|
|
376
|
+
"""
|
|
377
|
+
filter: [Resource]Filter
|
|
378
|
+
|
|
379
|
+
"""
|
|
380
|
+
Ordering specification
|
|
381
|
+
"""
|
|
382
|
+
orderBy: [Resource]OrderBy
|
|
383
|
+
): [Resource]Connection!
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
# -----------------------------------------------------------------------------
|
|
387
|
+
# MUTATIONS
|
|
388
|
+
# -----------------------------------------------------------------------------
|
|
389
|
+
|
|
390
|
+
type Mutation {
|
|
391
|
+
# ---------------------------------------------------------------------------
|
|
392
|
+
# [Resource] Mutations
|
|
393
|
+
# ---------------------------------------------------------------------------
|
|
394
|
+
|
|
395
|
+
"""
|
|
396
|
+
Create a new [resource]
|
|
397
|
+
"""
|
|
398
|
+
create[Resource](
|
|
399
|
+
"""
|
|
400
|
+
Input data for the new [resource]
|
|
401
|
+
"""
|
|
402
|
+
input: Create[Resource]Input!
|
|
403
|
+
): Create[Resource]Payload!
|
|
404
|
+
|
|
405
|
+
"""
|
|
406
|
+
Update an existing [resource]
|
|
407
|
+
"""
|
|
408
|
+
update[Resource](
|
|
409
|
+
"""
|
|
410
|
+
Input data for the update
|
|
411
|
+
"""
|
|
412
|
+
input: Update[Resource]Input!
|
|
413
|
+
): Update[Resource]Payload!
|
|
414
|
+
|
|
415
|
+
"""
|
|
416
|
+
Delete a [resource]
|
|
417
|
+
"""
|
|
418
|
+
delete[Resource](
|
|
419
|
+
"""
|
|
420
|
+
ID of the [resource] to delete
|
|
421
|
+
"""
|
|
422
|
+
id: ID!
|
|
423
|
+
): Delete[Resource]Payload!
|
|
424
|
+
|
|
425
|
+
"""
|
|
426
|
+
[Custom action] on a [resource]
|
|
427
|
+
"""
|
|
428
|
+
[action][Resource](
|
|
429
|
+
"""
|
|
430
|
+
Input data for the action
|
|
431
|
+
"""
|
|
432
|
+
input: [Action][Resource]Input!
|
|
433
|
+
): [Action][Resource]Payload!
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
# -----------------------------------------------------------------------------
|
|
437
|
+
# INPUTS: Mutations
|
|
438
|
+
# -----------------------------------------------------------------------------
|
|
439
|
+
|
|
440
|
+
"""
|
|
441
|
+
Input for creating a [resource]
|
|
442
|
+
"""
|
|
443
|
+
input Create[Resource]Input {
|
|
444
|
+
"""
|
|
445
|
+
[Description of required field]
|
|
446
|
+
"""
|
|
447
|
+
[requiredField]: [Type]!
|
|
448
|
+
|
|
449
|
+
"""
|
|
450
|
+
[Description of optional field]
|
|
451
|
+
"""
|
|
452
|
+
[optionalField]: [Type]
|
|
453
|
+
|
|
454
|
+
"""
|
|
455
|
+
Idempotency key for safe retries
|
|
456
|
+
"""
|
|
457
|
+
clientMutationId: String
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
"""
|
|
461
|
+
Input for updating a [resource]
|
|
462
|
+
"""
|
|
463
|
+
input Update[Resource]Input {
|
|
464
|
+
"""
|
|
465
|
+
ID of the [resource] to update
|
|
466
|
+
"""
|
|
467
|
+
id: ID!
|
|
468
|
+
|
|
469
|
+
"""
|
|
470
|
+
[Description of updatable field]
|
|
471
|
+
"""
|
|
472
|
+
[field]: [Type]
|
|
473
|
+
|
|
474
|
+
"""
|
|
475
|
+
Idempotency key for safe retries
|
|
476
|
+
"""
|
|
477
|
+
clientMutationId: String
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
"""
|
|
481
|
+
Input for [custom action] on a [resource]
|
|
482
|
+
"""
|
|
483
|
+
input [Action][Resource]Input {
|
|
484
|
+
"""
|
|
485
|
+
ID of the [resource]
|
|
486
|
+
"""
|
|
487
|
+
id: ID!
|
|
488
|
+
|
|
489
|
+
"""
|
|
490
|
+
[Action-specific parameters]
|
|
491
|
+
"""
|
|
492
|
+
[param]: [Type]!
|
|
493
|
+
|
|
494
|
+
"""
|
|
495
|
+
Idempotency key for safe retries
|
|
496
|
+
"""
|
|
497
|
+
clientMutationId: String
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
# -----------------------------------------------------------------------------
|
|
501
|
+
# PAYLOADS: Mutations
|
|
502
|
+
# -----------------------------------------------------------------------------
|
|
503
|
+
|
|
504
|
+
"""
|
|
505
|
+
Payload returned from create[Resource] mutation
|
|
506
|
+
"""
|
|
507
|
+
type Create[Resource]Payload {
|
|
508
|
+
"""
|
|
509
|
+
The created [resource], null if errors occurred
|
|
510
|
+
"""
|
|
511
|
+
[resource]: [Resource]
|
|
512
|
+
|
|
513
|
+
"""
|
|
514
|
+
Errors that occurred during the mutation
|
|
515
|
+
"""
|
|
516
|
+
errors: [UserError!]!
|
|
517
|
+
|
|
518
|
+
"""
|
|
519
|
+
Client mutation ID for request correlation
|
|
520
|
+
"""
|
|
521
|
+
clientMutationId: String
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
"""
|
|
525
|
+
Payload returned from update[Resource] mutation
|
|
526
|
+
"""
|
|
527
|
+
type Update[Resource]Payload {
|
|
528
|
+
"""
|
|
529
|
+
The updated [resource], null if errors occurred
|
|
530
|
+
"""
|
|
531
|
+
[resource]: [Resource]
|
|
532
|
+
|
|
533
|
+
"""
|
|
534
|
+
Errors that occurred during the mutation
|
|
535
|
+
"""
|
|
536
|
+
errors: [UserError!]!
|
|
537
|
+
|
|
538
|
+
"""
|
|
539
|
+
Client mutation ID for request correlation
|
|
540
|
+
"""
|
|
541
|
+
clientMutationId: String
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
"""
|
|
545
|
+
Payload returned from delete[Resource] mutation
|
|
546
|
+
"""
|
|
547
|
+
type Delete[Resource]Payload {
|
|
548
|
+
"""
|
|
549
|
+
ID of the deleted [resource]
|
|
550
|
+
"""
|
|
551
|
+
deletedId: ID
|
|
552
|
+
|
|
553
|
+
"""
|
|
554
|
+
Errors that occurred during the mutation
|
|
555
|
+
"""
|
|
556
|
+
errors: [UserError!]!
|
|
557
|
+
|
|
558
|
+
"""
|
|
559
|
+
Client mutation ID for request correlation
|
|
560
|
+
"""
|
|
561
|
+
clientMutationId: String
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
"""
|
|
565
|
+
Payload returned from [action][Resource] mutation
|
|
566
|
+
"""
|
|
567
|
+
type [Action][Resource]Payload {
|
|
568
|
+
"""
|
|
569
|
+
The [resource] after the action
|
|
570
|
+
"""
|
|
571
|
+
[resource]: [Resource]
|
|
572
|
+
|
|
573
|
+
"""
|
|
574
|
+
[Action-specific result fields]
|
|
575
|
+
"""
|
|
576
|
+
[resultField]: [Type]
|
|
577
|
+
|
|
578
|
+
"""
|
|
579
|
+
Errors that occurred during the mutation
|
|
580
|
+
"""
|
|
581
|
+
errors: [UserError!]!
|
|
582
|
+
|
|
583
|
+
"""
|
|
584
|
+
Client mutation ID for request correlation
|
|
585
|
+
"""
|
|
586
|
+
clientMutationId: String
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
# -----------------------------------------------------------------------------
|
|
590
|
+
# ERROR TYPES
|
|
591
|
+
# -----------------------------------------------------------------------------
|
|
592
|
+
|
|
593
|
+
"""
|
|
594
|
+
A user-facing error from a mutation
|
|
595
|
+
"""
|
|
596
|
+
type UserError {
|
|
597
|
+
"""
|
|
598
|
+
The field that caused the error, if applicable
|
|
599
|
+
Path format: ["input", "fieldName"]
|
|
600
|
+
"""
|
|
601
|
+
path: [String!]
|
|
602
|
+
|
|
603
|
+
"""
|
|
604
|
+
Machine-readable error code
|
|
605
|
+
"""
|
|
606
|
+
code: UserErrorCode!
|
|
607
|
+
|
|
608
|
+
"""
|
|
609
|
+
Human-readable error message
|
|
610
|
+
"""
|
|
611
|
+
message: String!
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
"""
|
|
615
|
+
Error codes for user-facing errors
|
|
616
|
+
"""
|
|
617
|
+
enum UserErrorCode {
|
|
618
|
+
"""
|
|
619
|
+
A required field was not provided
|
|
620
|
+
"""
|
|
621
|
+
REQUIRED_FIELD
|
|
622
|
+
|
|
623
|
+
"""
|
|
624
|
+
The provided value is invalid
|
|
625
|
+
"""
|
|
626
|
+
INVALID_VALUE
|
|
627
|
+
|
|
628
|
+
"""
|
|
629
|
+
The resource was not found
|
|
630
|
+
"""
|
|
631
|
+
NOT_FOUND
|
|
632
|
+
|
|
633
|
+
"""
|
|
634
|
+
The operation conflicts with current state
|
|
635
|
+
"""
|
|
636
|
+
CONFLICT
|
|
637
|
+
|
|
638
|
+
"""
|
|
639
|
+
The user is not authorized for this operation
|
|
640
|
+
"""
|
|
641
|
+
UNAUTHORIZED
|
|
642
|
+
|
|
643
|
+
"""
|
|
644
|
+
A business rule was violated
|
|
645
|
+
"""
|
|
646
|
+
BUSINESS_RULE_VIOLATION
|
|
647
|
+
|
|
648
|
+
"""
|
|
649
|
+
Rate limit exceeded
|
|
650
|
+
"""
|
|
651
|
+
RATE_LIMITED
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
# -----------------------------------------------------------------------------
|
|
655
|
+
# SUBSCRIPTIONS (if applicable)
|
|
656
|
+
# -----------------------------------------------------------------------------
|
|
657
|
+
|
|
658
|
+
type Subscription {
|
|
659
|
+
"""
|
|
660
|
+
Subscribe to [resource] changes
|
|
661
|
+
"""
|
|
662
|
+
[resource]Changed(
|
|
663
|
+
"""
|
|
664
|
+
Optional filter to specific [resource] ID
|
|
665
|
+
"""
|
|
666
|
+
id: ID
|
|
667
|
+
): [Resource]ChangePayload!
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
"""
|
|
671
|
+
Payload for [resource] change subscription
|
|
672
|
+
"""
|
|
673
|
+
type [Resource]ChangePayload {
|
|
674
|
+
"""
|
|
675
|
+
The type of change that occurred
|
|
676
|
+
"""
|
|
677
|
+
changeType: ChangeType!
|
|
678
|
+
|
|
679
|
+
"""
|
|
680
|
+
The [resource] after the change (null for DELETE)
|
|
681
|
+
"""
|
|
682
|
+
[resource]: [Resource]
|
|
683
|
+
|
|
684
|
+
"""
|
|
685
|
+
ID of the affected [resource]
|
|
686
|
+
"""
|
|
687
|
+
[resource]Id: ID!
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
"""
|
|
691
|
+
Types of changes for subscriptions
|
|
692
|
+
"""
|
|
693
|
+
enum ChangeType {
|
|
694
|
+
CREATED
|
|
695
|
+
UPDATED
|
|
696
|
+
DELETED
|
|
697
|
+
}
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
## Usage Instructions
|
|
701
|
+
|
|
702
|
+
1. Copy the template into your schema file(s)
|
|
703
|
+
2. Replace all `[bracketed]` placeholders with actual values
|
|
704
|
+
3. Remove sections that don't apply (e.g., Subscriptions if not needed)
|
|
705
|
+
4. Add your custom scalars if using libraries like graphql-scalars
|
|
706
|
+
5. Ensure all types implement Node if using Relay
|
|
707
|
+
6. Add descriptions to ALL types and fields
|
|
708
|
+
|
|
709
|
+
## Design Patterns Applied
|
|
710
|
+
|
|
711
|
+
### Relay Specification Compliance
|
|
712
|
+
|
|
713
|
+
- **Node interface**: All fetchable types implement `Node` with global ID
|
|
714
|
+
- **Connection pattern**: Paginated lists use `edges`, `node`, `cursor`, `pageInfo`
|
|
715
|
+
- **Global IDs**: Use base64-encoded `type:id` format for Relay compatibility
|
|
716
|
+
|
|
717
|
+
### Input/Payload Pattern
|
|
718
|
+
|
|
719
|
+
- **Inputs**: All mutation arguments wrapped in a single `input` argument
|
|
720
|
+
- **Payloads**: All mutations return a payload with the result AND errors array
|
|
721
|
+
- **clientMutationId**: Included for idempotency and request correlation
|
|
722
|
+
|
|
723
|
+
### Error Handling
|
|
724
|
+
|
|
725
|
+
- **UserError type**: Field-level errors with path, code, and message
|
|
726
|
+
- **Non-null errors array**: Always returns `errors: [UserError!]!` (empty if success)
|
|
727
|
+
- **Nullable result**: Main result field is nullable (null when errors exist)
|
|
728
|
+
|
|
729
|
+
## Customization Options
|
|
730
|
+
|
|
731
|
+
### For Simpler APIs
|
|
732
|
+
|
|
733
|
+
Remove Relay patterns if not needed:
|
|
734
|
+
|
|
735
|
+
```graphql
|
|
736
|
+
# Instead of Connection pattern
|
|
737
|
+
type Query {
|
|
738
|
+
users(limit: Int, offset: Int): [User!]!
|
|
739
|
+
}
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
### For Real-time Features
|
|
743
|
+
|
|
744
|
+
Expand subscriptions with more granular events:
|
|
745
|
+
|
|
746
|
+
```graphql
|
|
747
|
+
type Subscription {
|
|
748
|
+
resourceCreated: Resource!
|
|
749
|
+
resourceUpdated(id: ID!): Resource!
|
|
750
|
+
resourceDeleted: ID!
|
|
751
|
+
}
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
### For Federation
|
|
755
|
+
|
|
756
|
+
Add directives for Apollo Federation:
|
|
757
|
+
|
|
758
|
+
```graphql
|
|
759
|
+
type User @key(fields: "id") {
|
|
760
|
+
id: ID!
|
|
761
|
+
# ... fields
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
extend type Query {
|
|
765
|
+
_entities(representations: [_Any!]!): [_Entity]!
|
|
766
|
+
_service: _Service!
|
|
767
|
+
}
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
## Anti-patterns to Avoid
|
|
771
|
+
|
|
772
|
+
```graphql
|
|
773
|
+
# BAD: Inconsistent nullability
|
|
774
|
+
type User {
|
|
775
|
+
name: String # Should be String! if always present
|
|
776
|
+
email: String! # Good
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
# BAD: No connection pattern for lists
|
|
780
|
+
type Query {
|
|
781
|
+
allUsers: [User] # Use UserConnection for pagination
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
# BAD: Generic mutation payloads
|
|
785
|
+
type MutationResult {
|
|
786
|
+
success: Boolean!
|
|
787
|
+
message: String
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
# BAD: No error handling in mutations
|
|
791
|
+
type Mutation {
|
|
792
|
+
createUser(name: String!): User # Should return CreateUserPayload
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
# BAD: Deeply nested inputs
|
|
796
|
+
input CreateOrderInput {
|
|
797
|
+
items: [CreateOrderItemInput!]! # OK, one level
|
|
798
|
+
}
|
|
799
|
+
input CreateOrderItemInput {
|
|
800
|
+
product: CreateProductInput! # BAD, creates products inline
|
|
801
|
+
}
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
## Schema Checklist
|
|
805
|
+
|
|
806
|
+
Before finalizing:
|
|
807
|
+
- [ ] All types have descriptions
|
|
808
|
+
- [ ] All fields have descriptions
|
|
809
|
+
- [ ] Nullability is intentional and consistent
|
|
810
|
+
- [ ] Connections used for paginated lists
|
|
811
|
+
- [ ] Mutations return payloads with errors array
|
|
812
|
+
- [ ] Enums use SCREAMING_SNAKE_CASE
|
|
813
|
+
- [ ] Input types are suffixed with `Input`
|
|
814
|
+
- [ ] Payload types are suffixed with `Payload`
|
|
815
|
+
- [ ] Filter types are suffixed with `Filter`
|
|
816
|
+
- [ ] N+1 query potential identified and addressed
|
|
817
|
+
- [ ] Deprecated fields marked with `@deprecated(reason: "...")`
|
|
818
|
+
- [ ] No circular type dependencies without interfaces
|