@gambalabs/apollo 6.0.0-alpha.20 → 6.0.0-alpha.23
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/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -2
- package/dist/runtime/plugin.mjs +30 -11
- package/dist/shared/{apollo.d410709a.d.mts → apollo.c5299a22.d.mts} +14 -0
- package/dist/shared/{apollo.d410709a.d.ts → apollo.c5299a22.d.ts} +14 -0
- package/package.json +1 -1
package/dist/config.d.mts
CHANGED
package/dist/config.d.ts
CHANGED
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { N as NuxtApolloConfig, C as ClientConfig } from './shared/apollo.
|
|
2
|
+
import { N as NuxtApolloConfig, C as ClientConfig } from './shared/apollo.c5299a22.mjs';
|
|
3
3
|
export { ErrorResponse } from '@apollo/client/link/error';
|
|
4
4
|
import 'graphql-ws';
|
|
5
5
|
import '@apollo/client';
|
package/dist/module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { N as NuxtApolloConfig, C as ClientConfig } from './shared/apollo.
|
|
2
|
+
import { N as NuxtApolloConfig, C as ClientConfig } from './shared/apollo.c5299a22.js';
|
|
3
3
|
export { ErrorResponse } from '@apollo/client/link/error';
|
|
4
4
|
import 'graphql-ws';
|
|
5
5
|
import '@apollo/client';
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { useLogger, defineNuxtModule, createResolver, addTemplate, addPlugin, ad
|
|
|
5
5
|
import GraphQLPlugin from '@rollup/plugin-graphql';
|
|
6
6
|
|
|
7
7
|
const name = "@gambalabs/apollo";
|
|
8
|
-
const version = "6.0.0-alpha.
|
|
8
|
+
const version = "6.0.0-alpha.23";
|
|
9
9
|
|
|
10
10
|
const serializeConfig = (obj) => {
|
|
11
11
|
if (typeof obj === "function") {
|
|
@@ -46,7 +46,8 @@ const module = defineNuxtModule({
|
|
|
46
46
|
secure: process.env.NODE_ENV === "production",
|
|
47
47
|
sameSite: "lax"
|
|
48
48
|
},
|
|
49
|
-
clientAwareness: false
|
|
49
|
+
clientAwareness: false,
|
|
50
|
+
requestMaxTimeout: 7e3
|
|
50
51
|
},
|
|
51
52
|
async setup(options, nuxt) {
|
|
52
53
|
if (!options.clients || !Object.keys(options.clients).length) {
|
|
@@ -85,6 +86,7 @@ const module = defineNuxtModule({
|
|
|
85
86
|
v.csrfHeader = v?.csrfHeader || options.csrfHeader;
|
|
86
87
|
v.tokenName = v?.tokenName || `apollo:${k}.token`;
|
|
87
88
|
v.tokenStorage = v?.tokenStorage || options.tokenStorage;
|
|
89
|
+
v.requestMaxTimeout = v?.requestMaxTimeout || options.requestMaxTimeout;
|
|
88
90
|
if (v.cookieAttributes) {
|
|
89
91
|
v.cookieAttributes = defu(v?.cookieAttributes, options.cookieAttributes);
|
|
90
92
|
}
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -92,17 +92,36 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
92
92
|
if (clientConfig.persistedQueries) {
|
|
93
93
|
persistedLink = createPersistedQueryLink({ sha256, useGETForHashedQueries: true });
|
|
94
94
|
}
|
|
95
|
-
const customFetch = async (uri, options
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
const customFetch = async (uri, options) => {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
let handledByTimeout = false;
|
|
98
|
+
const timer = setTimeout(() => {
|
|
99
|
+
handledByTimeout = true;
|
|
100
|
+
nuxtApp.callHook("apollo:error", {
|
|
101
|
+
networkError: {
|
|
102
|
+
bodyText: `Request Exceeded timeout ${clientConfig.requestMaxTimeout}ms`,
|
|
103
|
+
statusCode: "(failed)net::ERR_NAME_NOT_RESOLVED",
|
|
104
|
+
options
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
reject(new Error(`Request Exceeded timeout ${clientConfig.requestMaxTimeout}ms`));
|
|
108
|
+
}, clientConfig.requestMaxTimeout);
|
|
109
|
+
fetch(uri, options).then(async (response) => {
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
if (response.status >= 300) {
|
|
112
|
+
const errorText = await response.clone().text();
|
|
113
|
+
nuxtApp.callHook("apollo:error", { networkError: { bodyText: errorText, statusCode: response.status, options } });
|
|
114
|
+
}
|
|
115
|
+
resolve(response);
|
|
116
|
+
}).catch((e) => {
|
|
117
|
+
if (handledByTimeout) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
clearTimeout(timer);
|
|
121
|
+
nuxtApp.callHook("apollo:error", { networkError: { bodyText: "Failed to fetch", statusCode: "(failed)net::ERR_NAME_NOT_RESOLVED", options } });
|
|
122
|
+
reject(e);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
106
125
|
};
|
|
107
126
|
const httpEndLink = createUploadLink({
|
|
108
127
|
...clientConfig?.httpLinkOptions && clientConfig.httpLinkOptions,
|
|
@@ -120,6 +120,13 @@ type ClientConfig = {
|
|
|
120
120
|
*/
|
|
121
121
|
csrfHeader?: string
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Request maximum timeout.
|
|
125
|
+
* @type {number}
|
|
126
|
+
* @default 7000
|
|
127
|
+
*/
|
|
128
|
+
requestMaxTimeout?: number
|
|
129
|
+
|
|
123
130
|
/**
|
|
124
131
|
* Enable automatic persisted queries.
|
|
125
132
|
* @type {boolean}
|
|
@@ -176,6 +183,13 @@ interface NuxtApolloConfig<T = false> {
|
|
|
176
183
|
*/
|
|
177
184
|
csrfHeader?: string;
|
|
178
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Request maximum timeout.
|
|
188
|
+
* @type {number}
|
|
189
|
+
* @default 7000
|
|
190
|
+
*/
|
|
191
|
+
requestMaxTimeout?: number
|
|
192
|
+
|
|
179
193
|
/**
|
|
180
194
|
* Specify if the auth token should be stored in `cookie` or `localStorage`.
|
|
181
195
|
* `Cookie` storage is required for SSR.
|
|
@@ -120,6 +120,13 @@ type ClientConfig = {
|
|
|
120
120
|
*/
|
|
121
121
|
csrfHeader?: string
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Request maximum timeout.
|
|
125
|
+
* @type {number}
|
|
126
|
+
* @default 7000
|
|
127
|
+
*/
|
|
128
|
+
requestMaxTimeout?: number
|
|
129
|
+
|
|
123
130
|
/**
|
|
124
131
|
* Enable automatic persisted queries.
|
|
125
132
|
* @type {boolean}
|
|
@@ -176,6 +183,13 @@ interface NuxtApolloConfig<T = false> {
|
|
|
176
183
|
*/
|
|
177
184
|
csrfHeader?: string;
|
|
178
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Request maximum timeout.
|
|
188
|
+
* @type {number}
|
|
189
|
+
* @default 7000
|
|
190
|
+
*/
|
|
191
|
+
requestMaxTimeout?: number
|
|
192
|
+
|
|
179
193
|
/**
|
|
180
194
|
* Specify if the auth token should be stored in `cookie` or `localStorage`.
|
|
181
195
|
* `Cookie` storage is required for SSR.
|