Skip to content

Commit d84be9c

Browse files
committed
feat(docs): add operation name
1 parent 6b06530 commit d84be9c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

internal/website/docs/client/fetching-data.mdx

+22
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ if (possibleData instanceof Promise) {
6060
}
6161
```
6262

63+
### Operation name
64+
65+
A custom operation name can be added to GraphQL queries, mutations and subscriptions.
66+
67+
This is useful when mocking for unit tests, and advanced server logics.
68+
69+
```ts
70+
import { query, resolved, inlineResolved } from '../gqty';
71+
72+
resolved(() => query.helloWorld, { operationName: 'MyQuery' });
73+
74+
inlineResolved(() => query.helloWorld, { operationName: 'MyQuery' });
75+
```
76+
77+
Both `resolved` and `inlineResolved` above will generate the following query:
78+
79+
```graphql
80+
query MyQuery {
81+
helloWorld
82+
}
83+
```
84+
6385
## track
6486

6587
The function `track` accepts a callback that gets automatically called every time related data arrives or related cache changes, particularly useful for subscriptions, but it also works for queries.

0 commit comments

Comments
 (0)