@burojs/hasura 0.2.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,22 +56,21 @@ registry rather than by branching on resource names:
56
56
  | `dataBody` | route a heavy array payload into/out of a 1:1 sibling table |
57
57
  | `live` | opt this resource into subscription-driven invalidation |
58
58
 
59
- #### `recoverAuth` fires on HTTP 401 — which is not how Hasura rejects a credential
60
-
61
- `config.recoverAuth` is consulted when a request comes back with HTTP **401**,
62
- and only then. The one capture in this repository of a real Hasura rejection —
63
- `packages/mock-kit/fixtures/hasura/error-unauthorized.json`, taken from a live
64
- backend with a deliberately malformed bearer token — came back **HTTP 200 with
65
- an `invalid-jwt` errors envelope**. Replayed through this provider that
66
- surfaces as `{ kind: 'protocol', code: 'graphql-error' }`, `recoverAuth` is
67
- never called, and app logic keyed on `kind: 'auth'` never fires either.
68
-
69
- So `recoverAuth` is useful for a deployment that really answers 401 (a proxy or
70
- gateway in front of Hasura); against Hasura's own rejection shape it is inert.
71
- The behaviour is pinned by `tests/fixture-fidelity.test.ts`'s
72
- `error-unauthorized` case, and the package's existing 401-recovery tests use a
73
- fabricated 401 — they are not evidence about Hasura. Keying recovery on the
74
- error envelope is a product decision this package has not taken.
59
+ #### Errors Hasura sends with HTTP 200
60
+
61
+ Hasura answers every GraphQL-level failure with HTTP 200, so the provider
62
+ classifies the envelope by `extensions.code`: `access-denied` and
63
+ `permission-error` reject as `{ kind: 'forbidden', code }`, `invalid-jwt` as
64
+ `{ kind: 'auth', code: 'invalid-jwt' }`, and every other code as
65
+ `{ kind: 'protocol', code: 'graphql-error' }`. When the app passes an
66
+ `authProvider` to `<BuroProvider>`, an `auth` rejection reaches its `onError`,
67
+ which decides whether to refresh; on `refreshed` the runtime replays a read once
68
+ (a mutation once when it is replay-safe). `config.recoverAuth` remains the hook
69
+ for an HTTP **401**, which a proxy or gateway in front of Hasura answers; it is
70
+ not consulted for the envelope. A mutation whose request was sent and got no
71
+ answer at all rejects as `{ kind: 'sent', code: 'hasura-request-sent',
72
+ retryable: false }`: it may have been applied. Pinned by
73
+ `tests/fixture-fidelity.test.ts` and `tests/error-kinds.test.ts`.
75
74
 
76
75
  Optimistic concurrency is available per call: pass
77
76
  `providerOptions.ifUpdatedAt` on an update and the mutation switches to a