Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 40 additions & 23 deletions GAP-0/DRAFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,26 @@ TransformOperation(document, selectionSet) :
remove it.
1. Return {document}.

**Lists**

When `@mock` is applied to a selection which is a child of a list type, the
client inserts the same _mock value_ in each corresponding array element in
the repsonse.

For example, this query inserts the same {"blurHash"} value for each item in
{"menuItems"}:

```graphql example
query GetMenuItemPhotos {
business(id: "123") {
menuItems {
name
blurHash @mock(value: "L15hfK~ot5NL$_?GRjIV?vW?M{RP")
}
}
}
```

# Mock Files

:: A *mock file* is a `.json` file that maps each *mock variant id* to a
Expand Down Expand Up @@ -271,30 +291,12 @@ A *mock variant* object may contain **only** the following keys:

#### data

:: {"data"} stores the *mock value*. It may be a scalar, object, or `null`,
depending on what in the operation is being mocked.

The client inserts {"data"} directly under the {"data"} key of the operation's
response — it must not be nested inside an additional {"data"} entry.
:: {"data"} stores the *mock value*. It may be a scalar, object, array, or
`null`, depending on what in the operation is being mocked.

For example, when `@mock` is applied to an operation root, the *mock variant*
should look like this:

```json example
{
"mock-id": {
"data": {
"business": {
"name": "The Great British Bakery",
"rating": 5.0
}
},
"__path__": "Query"
}
}
```

Not this:
The client merges {"data"} directly into the {"data"} field of the operation's
response — it must not be nested inside an additional {"data"} entry in the
_mock variant_:

```json counter-example
{
Expand All @@ -312,6 +314,21 @@ Not this:
}
```

When applying `@mock` to a field that returns a list type, {"data"} contains the
list value directly:

```json example
{
"menu-items": {
"data": [
{ "name": "Pancakes", "price": "$8.00" },
{ "name": "Waffles", "price": "$9.00" }
],
"__path__": "business.menuItems"
}
}
```

#### errors

{"errors"} may contain an array of error objects conforming to the
Expand Down