···11---
22title: Errors
33-order: 7
33+order: 8
44---
5566# Help!
···411411412412Please make sure that you're not calling `cache.updateQuery`,
413413`cache.writeFragment`, or `cache.link` inside `resolvers`.
414414+415415+## (28) Resolver and directive match the same field
416416+417417+When you have a resolver defined on a field you shouln't be combining it with a directive as the directive
418418+will apply and the resolver will be void.
+35
docs/graphcache/local-directives.md
···11+---
22+title: Local Directives
33+order: 3
44+---
55+66+# Local Directives
77+88+Graphcache supports adding directives to GraphQL Documents, when we prefix a
99+directive with an underscore (`_`) it will be stripped from the document and stored
1010+on the `_directives` property on the AST-node.
1111+1212+> Ensure you prefix directives with `_` if you only want to alter local behavior.
1313+1414+By default graphcache will add two directives `@_optional` and `@_required` which
1515+allow you to mark fields as being optional or mandatory.
1616+1717+If you want to add directives yourself you can do so by performing
1818+1919+```js
2020+cacheExchange({
2121+ directives: {
2222+ // If you now add `@_pagination` to your document we will execute this
2323+ pagination: directiveArguments => () => {
2424+ /* Resolver */
2525+ },
2626+ },
2727+});
2828+```
2929+3030+The function signature of a directive is a function which receives the arguments the directive is called with in the document.
3131+That function should returns a [Resolver](./local-directives.md).
3232+3333+### Reading on
3434+3535+[On the next page we'll learn about "Cache Updates".](./cache-updates.md)
+1-1
docs/graphcache/local-resolvers.md
···565565566566### Reading on
567567568568-[On the next page we'll learn about "Cache Updates".](./cache-updates.md)
568568+[On the next page we'll learn about "Cache Directives".](./local-directives.md)
+1-1
docs/graphcache/offline.md
···11---
22title: Offline Support
33-order: 6
33+order: 7
44---
5566# Offline Support
···555555 * @see {@link https://urql.dev/goto/docs/graphcache/local-resolvers} for the full resolvers docs.
556556 */
557557 resolvers?: ResolverConfig;
558558+ /** Configures directives which can perform custom logic on fields.
559559+ *
560560+ * @remarks
561561+ * A {@link DirectivesConfig} may be passed to allow local directives to be used. For example, when `@_custom` is placed on a field and the configuration contains `custom` then this directive is executed by Graphcache.
562562+ *
563563+ * @see {@link https://urql.dev/goto/docs/graphcache/local-directives} for the full directives docs.
564564+ */
565565+ directives?: DirectivesConfig;
558566 /** Configures optimistic updates to react to mutations instantly before an API response.
559567 *
560568 * @remarks
···691699 [typeName: string]: {
692700 [fieldName: string]: Resolver | void;
693701 } | void;
702702+};
703703+704704+export type Directive = (
705705+ directiveArguments: Record<string, unknown> | null
706706+) => Resolver;
707707+708708+export type DirectivesConfig = {
709709+ [directiveName: string]: Directive;
694710};
695711696712/** Cache Updater, which defines additional cache updates after cache writes.