nextjs-hasura-auth 0.1.1 → 0.1.3
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/APOLLO.md +101 -174
- package/GENERATOR.md +4 -5
- package/README.md +9 -5
- package/dist/lib/apollo.d.ts +11 -9
- package/dist/lib/apollo.js +127 -90
- package/dist/lib/auth.d.ts +16 -0
- package/dist/lib/auth.js +159 -0
- package/dist/lib/authDbUtils.d.ts +48 -0
- package/dist/lib/authDbUtils.js +183 -0
- package/dist/lib/client.d.ts +81 -0
- package/dist/lib/client.js +353 -0
- package/dist/lib/email.d.ts +7 -0
- package/dist/lib/email.js +90 -0
- package/dist/lib/generator.d.ts +2 -7
- package/dist/lib/generator.js +394 -392
- package/dist/lib/graphql-proxy.d.ts +6 -0
- package/dist/lib/graphql-proxy.js +385 -0
- package/dist/lib/hasura-schema.d.ts +1 -0
- package/dist/lib/hasura-schema.js +65 -0
- package/dist/lib/hasura.d.ts +16 -0
- package/dist/lib/hasura.js +102 -0
- package/dist/lib/hooks/useCheckConnection.d.ts +7 -0
- package/dist/lib/hooks/useCheckConnection.js +62 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.js +5 -0
- package/dist/lib/test-utils.d.ts +11 -0
- package/dist/lib/test-utils.js +59 -0
- package/dist/lib/tokenUtils.d.ts +14 -0
- package/dist/lib/tokenUtils.js +94 -0
- package/dist/package.json +22 -4
- package/dist/public/hasura-schema.json +7995 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +17 -6
package/APOLLO.md
CHANGED
@@ -1,174 +1,101 @@
|
|
1
|
-
# Apollo Client Setup (`
|
2
|
-
|
3
|
-
This
|
4
|
-
|
5
|
-
##
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
function UserProfile() {
|
103
|
-
// Assume user ID is available, e.g., from session or props
|
104
|
-
const userId = '...';
|
105
|
-
|
106
|
-
const GET_USER = gql`
|
107
|
-
query GetUser($userId: uuid!) {
|
108
|
-
users_by_pk(id: $userId) {
|
109
|
-
id
|
110
|
-
name
|
111
|
-
email
|
112
|
-
}
|
113
|
-
}
|
114
|
-
`;
|
115
|
-
|
116
|
-
// The client from ApolloWrapper's context is used automatically
|
117
|
-
const { loading, error, data } = useQuery(GET_USER, {
|
118
|
-
variables: { userId }
|
119
|
-
});
|
120
|
-
|
121
|
-
// ... render logic ...
|
122
|
-
}
|
123
|
-
```
|
124
|
-
|
125
|
-
### Server-Side (SSR/SSG/Server Components/API Routes)
|
126
|
-
|
127
|
-
1. **Create Client Instance:** Use `createClient` directly. You need to decide how to authenticate:
|
128
|
-
* **Admin Access:** Pass the admin secret (e.g., from environment variables) using the `secret` option if you need privileged access.
|
129
|
-
* **User Access:** If running in the context of a specific user request, obtain their Hasura JWT (e.g., from session data, request headers) and pass it using the `token` option.
|
130
|
-
|
131
|
-
```typescript
|
132
|
-
// Example in an API Route or Server Component
|
133
|
-
import { createClient } from '@/lib/apollo'; // Adjust path
|
134
|
-
import { gql } from '@apollo/client';
|
135
|
-
// import { getToken } from "next-auth/jwt"
|
136
|
-
|
137
|
-
async function getUserDataOnServer(userId: string, request?: Request) {
|
138
|
-
// Option 1: Use Admin Secret for privileged access
|
139
|
-
// const client = createClient({
|
140
|
-
// secret: process.env.HASURA_ADMIN_SECRET // Ensure secret is available server-side
|
141
|
-
// });
|
142
|
-
|
143
|
-
// Option 2: Use User Token (if available from request/session)
|
144
|
-
// Example: const sessionToken = await getToken({ req: request, secret: process.env.NEXTAUTH_SECRET });
|
145
|
-
// const hasuraToken = sessionToken?.accessToken;
|
146
|
-
const client = createClient({
|
147
|
-
token: process.env.SOME_SERVICE_ACCOUNT_TOKEN_IF_NEEDED // Or fetch user token if applicable
|
148
|
-
// url: process.env.NEXT_PUBLIC_HASURA_GRAPHQL_URL // URL can also be passed explicitly
|
149
|
-
});
|
150
|
-
|
151
|
-
const GET_USER = gql`...`; // Your query
|
152
|
-
|
153
|
-
try {
|
154
|
-
const { data } = await client.query({
|
155
|
-
query: GET_USER,
|
156
|
-
variables: { userId },
|
157
|
-
// Important for server-side: Avoid using client-side cache
|
158
|
-
fetchPolicy: 'network-only',
|
159
|
-
});
|
160
|
-
return data.users_by_pk;
|
161
|
-
} catch (error) {
|
162
|
-
console.error('Error fetching user data:', error);
|
163
|
-
return null;
|
164
|
-
}
|
165
|
-
}
|
166
|
-
```
|
167
|
-
|
168
|
-
2. **Fetch Data:** Use `client.query(...)` or `client.mutate(...)`.
|
169
|
-
|
170
|
-
## Important Considerations
|
171
|
-
|
172
|
-
* **JWT Token:** Ensure your authentication system (like `next-auth`) generates a Hasura-compatible JWT containing the necessary `https://hasura.io/jwt/claims` and includes it in the session data (e.g., as `session.accessToken`) for the client-side integration to work.
|
173
|
-
* **Environment Variables:** Securely manage `HASURA_ADMIN_SECRET`, `NEXTAUTH_SECRET`, and potentially `HASURA_JWT_SECRET` using environment variable configuration in your hosting provider (e.g., Vercel). `NEXT_PUBLIC_HASURA_GRAPHQL_URL` needs to be accessible client-side.
|
174
|
-
* **WebSocket Security:** WebSocket connections initiated from the client include the token/secret directly in the `connectionParams`. Ensure your Hasura endpoint is properly secured (e.g., using HTTPS/WSS).
|
1
|
+
# Apollo Client Setup (`lib/apollo.tsx`)
|
2
|
+
|
3
|
+
This file provides the `useCreateApolloClient` hook, a crucial part of the library for interacting with your Hasura GraphQL backend.
|
4
|
+
|
5
|
+
## `useCreateApolloClient` Hook
|
6
|
+
|
7
|
+
A React hook to create and memoize an Apollo Client instance configured for the Hasura backend.
|
8
|
+
|
9
|
+
```tsx
|
10
|
+
import { useCreateApolloClient } from 'nextjs-hasura-auth';
|
11
|
+
|
12
|
+
function MyComponent() {
|
13
|
+
// Create client for HTTP only
|
14
|
+
const apolloClientHttp = useCreateApolloClient({ token: 'your-auth-token' });
|
15
|
+
|
16
|
+
// Create client for HTTP and WebSocket (subscriptions)
|
17
|
+
const apolloClientWs = useCreateApolloClient({ token: 'your-auth-token', ws: true });
|
18
|
+
|
19
|
+
// ... use apolloClient
|
20
|
+
}
|
21
|
+
```
|
22
|
+
|
23
|
+
### Purpose
|
24
|
+
|
25
|
+
This hook simplifies the setup of an Apollo Client tailored for Hasura environments, handling both HTTP and WebSocket connections, authentication headers, and role management.
|
26
|
+
|
27
|
+
### Arguments
|
28
|
+
|
29
|
+
- `options` (object):
|
30
|
+
- `token` (string | undefined): Optional authentication token (JWT) to be included in headers.
|
31
|
+
- `ws` (boolean): Optional flag (default: `false`) to enable WebSocket connection for subscriptions.
|
32
|
+
|
33
|
+
### Return Value
|
34
|
+
|
35
|
+
- `ApolloClient<NormalizedCacheObject>`: An initialized and memoized Apollo Client instance.
|
36
|
+
|
37
|
+
### Key Features
|
38
|
+
|
39
|
+
1. **HTTP Link (`httpLink`)**: Configured for standard GraphQL operations (queries, mutations) using `createHttpLink`.
|
40
|
+
2. **WebSocket Link (`wsLink`)**: Configured for GraphQL subscriptions using `graphql-ws`. Enabled only if `ws: true` is passed in the options. It uses `createClient` from `graphql-ws`.
|
41
|
+
3. **Role Link (`roleLink`)**: **New!** This is an `ApolloLink` middleware using `setContext` that intercepts outgoing **HTTP requests**. It checks the `context` object passed to the Apollo operation (e.g., in `useQuery`, `useMutation`). If a `role` property is found in the operation's context, it adds the `X-Hasura-Role` header to the HTTP request with the specified role.
|
42
|
+
* **Important Note:** This dynamic role setting via context currently **only works for HTTP requests** (queries and mutations). It **does not** dynamically set the role for WebSocket connections (subscriptions). For subscriptions, the role is determined by the `connectionParams` when the WebSocket connection is established, which typically uses the `token` provided to `useCreateApolloClient` to infer the role on the backend.
|
43
|
+
4. **Authentication Headers**:
|
44
|
+
* For HTTP requests, it automatically includes `Authorization: Bearer <token>` (if provided) and `X-Hasura-Admin-Secret` (if `process.env.HASURA_ADMIN_SECRET` is set). The `roleLink` adds the `X-Hasura-Role` header if a `role` is provided in the operation's context.
|
45
|
+
* For WebSocket connections, `connectionParams` are set with `headers` containing `Authorization` and `X-Hasura-Admin-Secret`.
|
46
|
+
5. **Request Splitting**: Uses `split` to direct operations to `httpLink` (via `roleLink` and `authLink`) or `wsLink` based on the operation type. Subscriptions go to `wsLink` (if `ws: true`), others go to `httpLink`.
|
47
|
+
6. **Error Handling (`errorLink`)**: Includes basic error logging for GraphQL and network errors using `onError`.
|
48
|
+
7. **Caching**: Uses `InMemoryCache` for client-side caching.
|
49
|
+
8. **Memoization**: The `useMemo` hook ensures the client instance is created only once per component lifecycle or when the `token` or `ws` options change, preventing unnecessary client recreations.
|
50
|
+
|
51
|
+
### How `roleLink` Works
|
52
|
+
|
53
|
+
The `roleLink` leverages Apollo Link's `setContext` middleware.
|
54
|
+
|
55
|
+
```typescript
|
56
|
+
// Simplified logic within useCreateApolloClient
|
57
|
+
import { setContext } from '@apollo/client/link/context';
|
58
|
+
|
59
|
+
const roleLink = setContext((_operation, context) => {
|
60
|
+
// context here is the *link* context, which includes headers etc.
|
61
|
+
// and importantly, the context passed from the hook/operation call.
|
62
|
+
const operationContext = context?.graphqlContext || {}; // Access context passed from useQuery/useMutation etc.
|
63
|
+
const role = operationContext.role; // Get the role from the operation's context
|
64
|
+
|
65
|
+
// If a role is provided in the operation's context, add it to the headers
|
66
|
+
if (role) {
|
67
|
+
return {
|
68
|
+
headers: {
|
69
|
+
...context.headers, // Preserve existing headers (like Authorization)
|
70
|
+
'X-Hasura-Role': role,
|
71
|
+
},
|
72
|
+
};
|
73
|
+
}
|
74
|
+
|
75
|
+
// Otherwise, return the existing headers unchanged
|
76
|
+
return {
|
77
|
+
headers: context.headers,
|
78
|
+
};
|
79
|
+
});
|
80
|
+
|
81
|
+
// This roleLink is then chained before the httpLink:
|
82
|
+
// link: from([errorLink, roleLink, authLink, httpLink]) // for HTTP
|
83
|
+
```
|
84
|
+
|
85
|
+
When you use the data fetching hooks from `lib/client.tsx` (like `useQuery`, `useMutation`) and pass a `role` in the `hookOptions`, that `role` becomes part of the operation's context (`graphqlContext`), which `roleLink` then reads to set the appropriate `X-Hasura-Role` header for that specific HTTP request.
|
86
|
+
|
87
|
+
```tsx
|
88
|
+
// Example using useQuery with a role
|
89
|
+
const { data } = useQuery(GET_POSTS, {
|
90
|
+
hookOptions: {
|
91
|
+
// These options are passed to Apollo's useQuery
|
92
|
+
variables: { limit: 10 },
|
93
|
+
// This context object is passed along the link chain
|
94
|
+
context: {
|
95
|
+
role: 'editor', // roleLink will pick this up
|
96
|
+
},
|
97
|
+
},
|
98
|
+
});
|
99
|
+
```
|
100
|
+
|
101
|
+
This allows for fine-grained role control on a per-operation basis for queries and mutations. Remember, WebSocket subscriptions rely on the role established during the initial connection based on the token.
|
package/GENERATOR.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Purpose
|
4
4
|
|
5
|
-
This document describes the `Generator` function located in `lib/generator.ts`. Its purpose is to dynamically generate GraphQL query strings, `DocumentNode` objects (compatible with Apollo Client), and corresponding variables based on a provided set of options and a Hasura-like schema (`schema.json`). This simplifies the process of constructing GraphQL operations (queries, mutations, subscriptions) within the application.
|
5
|
+
This document describes the `Generator` function located in `lib/generator.ts`. Its purpose is to dynamically generate GraphQL query strings, `DocumentNode` objects (compatible with Apollo Client), and corresponding variables based on a provided set of options and a Hasura-like schema (`public/hasura-schema.json`). This simplifies the process of constructing GraphQL operations (queries, mutations, subscriptions) within the application.
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
@@ -14,11 +14,10 @@ This document describes the `Generator` function located in `lib/generator.ts`.
|
|
14
14
|
// Assuming 'nextjs-hasura-auth' is your published package name
|
15
15
|
import { Generator, GenerateOptions, GenerateResult } from 'nextjs-hasura-auth';
|
16
16
|
// Assuming schema is correctly loaded (you might need to handle schema loading differently when using the package)
|
17
|
-
|
17
|
+
import schema from './public/hasura-schema.json';
|
18
18
|
|
19
19
|
// Initialize the generator (Schema needs to be passed)
|
20
|
-
|
21
|
-
// TODO: Document how schema should be provided when using the package
|
20
|
+
const generate = Generator(schema);
|
22
21
|
|
23
22
|
// Define options for your query
|
24
23
|
const options: GenerateOptions = {
|
@@ -77,7 +76,7 @@ The `generate` function accepts an object with the following properties:
|
|
77
76
|
|
78
77
|
## Examples
|
79
78
|
|
80
|
-
*(Note: Variable types like `users_bool_exp`, `[users_order_by!]`, `uuid!`, `users_pk_columns_input!`, `users_set_input!`, `[users_insert_input!]!` are inferred based on schema structure and conventions. Ensure your `schema.json` reflects the actual types used by Hasura.)*
|
79
|
+
*(Note: Variable types like `users_bool_exp`, `[users_order_by!]`, `uuid!`, `users_pk_columns_input!`, `users_set_input!`, `[users_insert_input!]!` are inferred based on schema structure and conventions. Ensure your `public/hasura-schema.json` reflects the actual types used by Hasura.)*
|
81
80
|
|
82
81
|
**Navigation**
|
83
82
|
|
package/README.md
CHANGED
@@ -4,6 +4,7 @@ This project provides a robust starting point for building applications using Ne
|
|
4
4
|
|
5
5
|
[](GENERATOR.md) [](APOLLO.md)
|
6
6
|
[](AUTH.md) [](HASURA.md)
|
7
|
+
[](CLIENT.md)
|
7
8
|
|
8
9
|
See [`GENERATOR.md`](GENERATOR.md) for detailed documentation on the dynamic GraphQL query generator, which simplifies creating queries, mutations, and subscriptions based on your Hasura schema.
|
9
10
|
|
@@ -13,6 +14,8 @@ See [`AUTH.md`](AUTH.md) for documentation on WebSocket and request authenticati
|
|
13
14
|
|
14
15
|
See [`HASURA.md`](HASURA.md) for details on the Hasura Admin API client used for migrations.
|
15
16
|
|
17
|
+
See [`CLIENT.md`](CLIENT.md) for details on the `Client` class and React hooks that combine the Generator and Apollo Client for easy data operations.
|
18
|
+
|
16
19
|
## ✨ Features Checklist
|
17
20
|
|
18
21
|
**Implemented:**
|
@@ -22,16 +25,17 @@ See [`HASURA.md`](HASURA.md) for details on the Hasura Admin API client used for
|
|
22
25
|
* [x] **Unified Apollo Client:** A configured Apollo Client instance handles both authenticated HTTP requests (via the proxy) and direct, authenticated WebSocket connections for subscriptions.
|
23
26
|
* [x] **Dynamic Query Generator:** A versatile query generator (`lib/generator.ts`) allows dynamic creation of GraphQL operations based on options and schema, suitable for client/server use.
|
24
27
|
* [x] **WebSocket Authentication:** Real-time subscriptions connect directly to Hasura via WebSockets, authenticated using the user's session JWT.
|
28
|
+
* [x] **Generated Client Wrapper:** A `Client` class and associated React hooks (`useQuery`, `useSubscription`) that combine the Generator and Apollo Client for simplified data fetching and mutations (`lib/client.tsx`).
|
25
29
|
|
26
30
|
**Planned / Future Ideas:**
|
27
31
|
|
28
|
-
* [ ] **Convenience Hooks:**
|
32
|
+
* [ ] **Advanced Convenience Hooks:** Potentially create a more advanced `useCRUD` hook/class built on top of the existing `Client` or hooks for even more streamlined common CRUD operations in components.
|
29
33
|
* [ ] **Multi-Platform Builds:** Native builders for Android, iOS, MacOS, Windows, Linux, Oculus (e.g., using Tauri, Capacitor, or Electron).
|
30
34
|
* [ ] **Unique Environment Builders:** Specific builds for Chrome Extensions, Firefox Extensions, and VSCode Extensions (including custom UI elements).
|
31
35
|
* [ ] Additional Authentication Providers (OAuth: Google, GitHub, etc.).
|
32
36
|
* [ ] Role-based access control examples.
|
33
37
|
* [ ] Advanced caching strategies.
|
34
|
-
* [ ] Comprehensive end-to-end testing setup.
|
38
|
+
* [ ] Comprehensive end-to-end testing setup for UI and hooks.
|
35
39
|
|
36
40
|
## 🚀 Core Concepts
|
37
41
|
|
@@ -67,7 +71,7 @@ Interaction with the Hasura GraphQL Engine is handled in two primary ways:
|
|
67
71
|
|
68
72
|
### 4. Dynamic Query Generation (`GENERATOR.md`)
|
69
73
|
|
70
|
-
* The core `Generator` function in `lib/generator.ts` allows you to build complex GraphQL operations dynamically based on a simple options object and your `schema.json`.
|
74
|
+
* The core `Generator` function in `lib/generator.ts` allows you to build complex GraphQL operations dynamically based on a simple options object and your `public/hasura-schema.json`.
|
71
75
|
* This avoids writing lengthy GraphQL query strings manually.
|
72
76
|
* See [`GENERATOR.md`](GENERATOR.md) for full usage details and examples.
|
73
77
|
* *Convenience hooks (like `useQuery`, `useSubscription`, `useCRUD`) are planned to further simplify using the generator within React components.*
|
@@ -89,10 +93,10 @@ Interaction with the Hasura GraphQL Engine is handled in two primary ways:
|
|
89
93
|
│ ├── debug.ts # Debug utility
|
90
94
|
│ └── ...
|
91
95
|
├── public/ # Static assets
|
96
|
+
│ ├── hasura-schema.json # Hasura GraphQL schema (for Generator)
|
92
97
|
├── styles/ # Global styles
|
93
98
|
├── .env # Environment variables (Gitignored)
|
94
99
|
├── GENERATOR.md # Query Generator Documentation
|
95
|
-
├── schema.json # Hasura GraphQL schema (for Generator)
|
96
100
|
├── next.config.js # Next.js configuration
|
97
101
|
├── package.json # Project dependencies and scripts
|
98
102
|
└── tsconfig.json # TypeScript configuration
|
@@ -159,7 +163,7 @@ Interaction with the Hasura GraphQL Engine is handled in two primary ways:
|
|
159
163
|
* Ensure `NEXTAUTH_URL` points to your application's base URL.
|
160
164
|
|
161
165
|
4. **Update Hasura Schema:**
|
162
|
-
Make sure the `schema.json` file in the root is up-to-date with your Hasura instance's schema. You might need to fetch this from Hasura if you've made changes.
|
166
|
+
Make sure the `public/hasura-schema.json` file in the root is up-to-date with your Hasura instance's schema. You might need to fetch this from Hasura if you've made changes.
|
163
167
|
|
164
168
|
5. **Run the development server:**
|
165
169
|
```bash
|
package/dist/lib/apollo.d.ts
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
import { ApolloClient } from '@apollo/client';
|
2
|
-
|
3
|
-
* Get JWT secret from environment variables
|
4
|
-
* @returns {Uint8Array} Secret key for JWT signing
|
5
|
-
*/
|
6
|
-
export declare const getJwtSecret: () => Uint8Array;
|
7
|
-
interface ApolloOptions {
|
2
|
+
export interface ApolloOptions {
|
8
3
|
url?: string;
|
9
4
|
ws?: boolean;
|
10
5
|
token?: string;
|
11
6
|
secret?: string;
|
12
7
|
}
|
8
|
+
export interface ApolloClientWithProvider extends ApolloClient<any> {
|
9
|
+
Provider: React.ComponentType<{
|
10
|
+
children: React.ReactNode;
|
11
|
+
}>;
|
12
|
+
}
|
13
13
|
/**
|
14
14
|
* Create Apollo Client
|
15
15
|
*
|
@@ -19,7 +19,7 @@ interface ApolloOptions {
|
|
19
19
|
* @param {string} options.secret - Admin secret for Hasura
|
20
20
|
* @returns {ApolloClient} Apollo Client
|
21
21
|
*/
|
22
|
-
export declare function
|
22
|
+
export declare function createApolloClient(options?: ApolloOptions): ApolloClientWithProvider;
|
23
23
|
/**
|
24
24
|
* Get or create Apollo client instance
|
25
25
|
* @param options Client options
|
@@ -30,14 +30,16 @@ export declare function getClient(options?: {}): ApolloClient<any>;
|
|
30
30
|
* React hook to get Apollo client instance
|
31
31
|
* @returns Apollo client instance
|
32
32
|
*/
|
33
|
-
export declare function
|
33
|
+
export declare function useCreateApolloClient(options: ApolloOptions): ApolloClientWithProvider;
|
34
|
+
export declare const CHECK_CONNECTION_SUBSCRIPTION: import("@apollo/client").DocumentNode;
|
35
|
+
export declare const CHECK_CONNECTION_QUERY: import("@apollo/client").DocumentNode;
|
34
36
|
/**
|
35
37
|
* Check connection to Hasura GraphQL endpoint
|
36
38
|
* @returns {Promise<boolean>} True if connection is successful
|
37
39
|
*/
|
38
40
|
export declare function checkConnection(client?: ApolloClient<any>): Promise<boolean>;
|
39
41
|
declare const _default: {
|
40
|
-
|
42
|
+
createApolloClient: typeof createApolloClient;
|
41
43
|
getClient: typeof getClient;
|
42
44
|
getJwtSecret: () => Uint8Array;
|
43
45
|
checkConnection: typeof checkConnection;
|