一键导入
graphql-mock
Create and edit mock values for GraphQL operations using the @mock directive
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create and edit mock values for GraphQL operations using the @mock directive
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | graphql-mock |
| description | Create and edit mock values for GraphQL operations using the @mock directive |
This skill manages mock values for GraphQL operations using the @mock
directive.
Mock files are located in __graphql_mocks__/{Name}.json adjacent to
the source file containing the operation or fragment. {Name} is the name of
that operation or fragment.
Each mock file is a JSON object where keys are "mock variant ids" and values are "mock variants".
A "mock variant" is an object containing the following attributes:
data (required): The mock value - the raw data to be returned - defined by https://spec.graphql.org/September2025/#sec-Data.errors: May contain an errors array - defined by https://spec.graphql.org/September2025/#sec-Errors.extensions: May contain arbitrary data - defined by https://spec.graphql.org/September2025/#sec-Extensions.__path__ (required): The field path within the operation or fragment where @mock is applied. A dot-separated string of field names (or aliases, where present) relative to the root. For @mock on an operation root, use the root operation type name (e.g., "Query", "Mutation", "Subscription"). When a field has an alias, use the alias in the path.__description__: A natural language description of the data being returned.__metadata__: May contain a key/value mapping of arbitrary data.Example
{
"5-star-business": {
"data": {
"business": {
"name": "The Great British Bakery",
"rating": 5.0
}
},
"__path__": "Query",
"__description__": "A delicious bakery with a rating of 5.0"
},
"has-no-rating": {
"data": {
"business": {
"name": "El Greco Deli",
"rating": null
}
},
"__path__": "Query",
"__description__": "A new restaurant which has not yet been rated - the rating field returns null"
}
}
When generating a new mock value, add the following to your context window:
When regenerating an existing mock value, also include the existing mock value payload and preserve as much as possible (unless the user has specified otherwise).
Ensure the generated mock value is valid against the selections in the operation or fragment.
Use plausible and realistic values, e.g., for "Business.name", use a made-up business name such as "The Great British Bakery". Avoid using "foo", "bar", "myBusiness", "string" etc. as values.
Generate a description field which summarizes the output, and has enough context such that it could be used to regenerate a similarly shaped payload.
When the mock should represent an error state, use the GraphQL errors format - unless you know that the schema uses a union to represent error state. You must check against the schema.
Example
{
"field-error": {
"data": { "fieldName": null },
"errors": [{
"path": ["fieldName"],
"message": "field error"
}],
"__path__": "fieldName"
}
}
When asked to add or update a mock variant:
__)data and/or errors fields__description__ fieldLook for the GraphQL schema in the repository to understand what shape of data
should be returned. (e.g., <repo_root>/schema.graphqls). Ask the user if the
schema file cannot be found, and remember where it is located.