···11+---
22+title: Errors
33+order: 6
44+---
55+16# Help!
2738**This document lists out all errors and warnings in `@urql/exchange-graphcache`.**
···914This is a supporting document that explains every error and attempts to give more
1015information on how you may be able to fix some issues or avoid these errors/warnings.
11161212-## (1) Invalid GraphQL document <a id="1"></a>
1717+## (1) Invalid GraphQL document
13181419> Invalid GraphQL document: All GraphQL documents must contain an OperationDefinition
1520> node for a query, subscription, or mutation.
···2227subscription. This error occurs when this is missing, because the `DocumentNode`
2328is maybe empty or only contains fragments.
24292525-## (2) Invalid Cache call <a id="2"></a>
3030+## (2) Invalid Cache call
26312732> Invalid Cache call: The cache may only be accessed or mutated during
2833> operations like write or query, or as part of its resolvers, updaters,
···4247This is a safe-guard to prevent any asynchronous work to take place, or to
4348avoid mutating the cache outside of any normal operation.
44494545-## (3) Invalid Object type <a id="3"></a>
5050+## (3) Invalid Object type
46514752> Invalid Object type: The type `???` is not an object in the defined schema,
4853> but the GraphQL document is traversing it.
···5560Check whether your schema is up-to-date or whether you're using an invalid
5661typename somewhere, maybe due to a typo.
57625858-## (4) Invalid field <a id="4"></a>
6363+## (4) Invalid field
59646065> Invalid field: The field `???` does not exist on `???`,
6166> but the GraphQL document expects it to exist.<br />
···7277As the warning states, this won't lead any operation to abort or an error
7378to be thrown!
74797575-## (5) Invalid Abstract type <a id="5"></a>
8080+## (5) Invalid Abstract type
76817782> Invalid Abstract type: The type `???` is not an Interface or Union type
7883> in the defined schema, but a fragment in the GraphQL document is using it
···8893Check whether your schema is up-to-date or whether you're using an invalid
8994field somewhere, maybe due to a typo.
90959191-## (6) readFragment(...) was called with an empty fragment <a id="6"></a>
9696+## (6) readFragment(...) was called with an empty fragment
92979398> readFragment(...) was called with an empty fragment.
9499> You have to call it with at least one fragment in your GraphQL document.
···102107When you're calling a fragment method, please ensure that you're only passing fragments
103108in your GraphQL document. The first fragment will be used to start writing data.
104109105105-## (7) Can't generate a key for readFragment(...) <a id="7"></a>
110110+## (7) Can't generate a key for readFragment(...)
106111107112> Can't generate a key for readFragment(...).
108113> You have to pass an `id` or `_id` field or create a custom `keys` config for `???`.
···116121Please make sure that you include enough properties on your data so that `readFragment`
117122can generate a key.
118123119119-## (8) Invalid resolver data <a id="8"></a>
124124+## (8) Invalid resolver data
120125121126> Invalid resolver value: The resolver at `???` returned an invalid typename that
122127> could not be reconciled with the cache.
···130135Please check your schema for the type that your resolver has to return, then add a
131136`__typename` field to your returned resolver value that matches this type.
132137133133-## (9) Invalid resolver value <a id="9"></a>
138138+## (9) Invalid resolver value
134139135140> Invalid resolver value: The field at `???` is a scalar (number, boolean, etc),
136141> but the GraphQL query expects a selection set for this field.
···144149Please check that your resolvers return scalars where there's no selection set,
145150and entities where there is one.
146151147147-## (10) writeOptimistic(...) was called with an operation that isn't a mutation <a id="10"></a>
152152+## (10) writeOptimistic(...) was called with an operation that isn't a mutation
148153149154> writeOptimistic(...) was called with an operation that is not a mutation.
150155> This case is unsupported and should never occur.
···152157This should never happen, please open an issue if it does. This occurs when `writeOptimistic`
153158attempts to write an optimistic result for a query or subscription, instead of a mutation.
154159155155-## (11) writeFragment(...) was called with an empty fragment <a id="11"></a>
160160+## (11) writeFragment(...) was called with an empty fragment
156161157162> writeFragment(...) was called with an empty fragment.
158163> You have to call it with at least one fragment in your GraphQL document.
···166171When you're calling a fragment method, please ensure that you're only passing fragments
167172in your GraphQL document. The first fragment will be used to start writing data.
168173169169-## (12) Can't generate a key for writeFragment(...) <a id="12"></a>
174174+## (12) Can't generate a key for writeFragment(...)
170175171176> Can't generate a key for writeFragment(...) data.
172177> You have to pass an `id` or `_id` field or create a custom `keys` config for `???`.
···180185Please make sure that you include enough properties on your data so that `writeFragment`
181186can generate a key.
182187183183-## (13) Invalid undefined <a id="13"></a>
188188+## (13) Invalid undefined
184189185190> Invalid undefined: The field at `???` is `undefined`, but the GraphQL query expects a
186191> scalar (number, boolean, etc) / selection set for this field.
···189194GraphQL results should never contain an `undefined` value, so this warning will let you
190195know which part of your result did contain `undefined`.
191196192192-## (15) Invalid key <a id="15"></a>
197197+## (15) Invalid key
193198194199> Invalid key: The GraphQL query at the field at `???` has a selection set,
195200> but no key could be generated for the data at this field.
···212217return a unique ID for your entity or it needs to explicitly return `null` to silence
213218this warning.
214219215215-## (16) Heuristic Fragment Matching <a id="16"></a>
220220+## (16) Heuristic Fragment Matching
216221217222> Heuristic Fragment Matching: A fragment is trying to match against the `???` type,
218223> but the type condition is `???`. Since GraphQL allows for interfaces `???` may be
···235240When you pass an introspected schema to the cache, this warning will never be displayed
236241as the cache can then do deterministic fragment matching using schema information.
237242238238-## (17) Invalid type <a id="17"></a>
243243+## (17) Invalid type
239244240245> Invalid type: The type `???` is used with @populate but does not exist.
241246···249254Check whether your schema is up-to-date or whether you're using an invalid
250255field somewhere, maybe due to a typo.
251256252252-## (18) Invalid TypeInfo state <a id="18"></a>
257257+## (18) Invalid TypeInfo state
253258254259> Invalid TypeInfo state: Found no flat schema type when one was expected.
255260···273278This may either happen because you're missing the `__typename` and `id` or `_id` field or if the last two
274279aren't applicable to this entity a custom `keys` entry.
275280276276-## (20) Invalid Object type <a id="20"></a>
281281+## (20) Invalid Object type
277282278283> Invalid Object type: The type `???` is not an object in the defined schema,
279284> but the `keys` option is referencing it.