@newmo/graphql-codegen-fake-server-client 0.23.1 → 0.23.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.
|
@@ -106,10 +106,10 @@ export type FakeClientRegisterSequenceOptions<TVariables = Record<string, any>>
|
|
|
106
106
|
});
|
|
107
107
|
};
|
|
108
108
|
const importQueryIdentifierName = (documentName) => {
|
|
109
|
-
return `import type { ${(0, convertName_1.convertName)(documentName, config)}Query, ${(0, convertName_1.convertName)(documentName, config)}QueryVariables } from
|
|
109
|
+
return `import type { ${(0, convertName_1.convertName)(documentName, config)}Query, ${(0, convertName_1.convertName)(documentName, config)}QueryVariables } from '${config.typesFile}';`;
|
|
110
110
|
};
|
|
111
111
|
const importMutationIdentifierName = (documentName) => {
|
|
112
|
-
return `import type { ${(0, convertName_1.convertName)(documentName, config)}Mutation, ${(0, convertName_1.convertName)(documentName, config)}MutationVariables } from
|
|
112
|
+
return `import type { ${(0, convertName_1.convertName)(documentName, config)}Mutation, ${(0, convertName_1.convertName)(documentName, config)}MutationVariables } from '${config.typesFile}';`;
|
|
113
113
|
};
|
|
114
114
|
const importsSection = documents
|
|
115
115
|
.flatMap((document) => {
|
|
@@ -15,6 +15,13 @@ export type CreateFakeClientOptions = {
|
|
|
15
15
|
fakeServerEndpoint: string;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
// Simple logger for FakeClient
|
|
19
|
+
const logger = {
|
|
20
|
+
error: (...args: unknown[]) => {
|
|
21
|
+
console.error('[FakeClient]', ...args);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
18
25
|
// Request queue implementation for rate limiting
|
|
19
26
|
class RequestQueue {
|
|
20
27
|
#queue: Array<() => Promise<unknown>> = [];
|
|
@@ -102,18 +109,17 @@ async function fetchWithRetry(
|
|
|
102
109
|
statusText: response.statusText,
|
|
103
110
|
attempt: attempt + 1,
|
|
104
111
|
maxAttempts,
|
|
105
|
-
|
|
112
|
+
body: options.body,
|
|
106
113
|
sequenceId: (options.headers as any)?.['sequence-id'],
|
|
107
114
|
};
|
|
108
115
|
|
|
109
|
-
|
|
116
|
+
logger.error('Server error, will retry:', requestInfo);
|
|
110
117
|
|
|
111
118
|
// Calculate delay with exponential backoff and jitter
|
|
112
119
|
const baseDelay = Math.min(initialDelay * Math.pow(backoffFactor, attempt), maxDelay);
|
|
113
120
|
const jitter = Math.random() * 0.1 * baseDelay; // 10% jitter
|
|
114
121
|
const delay = baseDelay + jitter;
|
|
115
122
|
|
|
116
|
-
console.log(\`[FakeClient] Retrying in \${Math.round(delay)}ms...\`);
|
|
117
123
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
118
124
|
continue;
|
|
119
125
|
}
|
|
@@ -144,11 +150,11 @@ async function fetchWithRetry(
|
|
|
144
150
|
error: error instanceof Error ? error.message : String(error),
|
|
145
151
|
attempt: attempt + 1,
|
|
146
152
|
maxAttempts,
|
|
147
|
-
|
|
153
|
+
body: options.body,
|
|
148
154
|
sequenceId: (options.headers as any)?.['sequence-id'],
|
|
149
155
|
};
|
|
150
156
|
|
|
151
|
-
|
|
157
|
+
logger.error('Request failed:', requestInfo);
|
|
152
158
|
|
|
153
159
|
if (shouldRetry && attempt < maxAttempts - 1) {
|
|
154
160
|
// Calculate delay with exponential backoff and jitter
|
|
@@ -156,7 +162,6 @@ async function fetchWithRetry(
|
|
|
156
162
|
const jitter = Math.random() * 0.1 * baseDelay; // 10% jitter
|
|
157
163
|
const delay = baseDelay + jitter;
|
|
158
164
|
|
|
159
|
-
console.log(\`[FakeClient] Retrying in \${Math.round(delay)}ms...\`);
|
|
160
165
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
161
166
|
continue;
|
|
162
167
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newmo/graphql-codegen-fake-server-client",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "GraphQL Codegen plugin for generating a fake server client",
|
|
6
6
|
"keywords": [
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"access": "public",
|
|
63
63
|
"registry": "https://registry.npmjs.org/"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "fdb857dc72e010f59daa8b274d027d495ddba6f1"
|
|
66
66
|
}
|
|
@@ -177,13 +177,13 @@ export type FakeClientRegisterSequenceOptions<TVariables = Record<string, any>>
|
|
|
177
177
|
return `import type { ${convertName(
|
|
178
178
|
documentName,
|
|
179
179
|
config,
|
|
180
|
-
)}Query, ${convertName(documentName, config)}QueryVariables } from
|
|
180
|
+
)}Query, ${convertName(documentName, config)}QueryVariables } from '${config.typesFile}';`;
|
|
181
181
|
};
|
|
182
182
|
const importMutationIdentifierName = (documentName: string) => {
|
|
183
183
|
return `import type { ${convertName(documentName, config)}Mutation, ${convertName(
|
|
184
184
|
documentName,
|
|
185
185
|
config,
|
|
186
|
-
)}MutationVariables } from
|
|
186
|
+
)}MutationVariables } from '${config.typesFile}';`;
|
|
187
187
|
};
|
|
188
188
|
const importsSection = documents
|
|
189
189
|
.flatMap((document) => {
|
package/src/templates/runtime.ts
CHANGED
|
@@ -12,6 +12,13 @@ export type CreateFakeClientOptions = {
|
|
|
12
12
|
fakeServerEndpoint: string;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
// Simple logger for FakeClient
|
|
16
|
+
const logger = {
|
|
17
|
+
error: (...args: unknown[]) => {
|
|
18
|
+
console.error('[FakeClient]', ...args);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
15
22
|
// Request queue implementation for rate limiting
|
|
16
23
|
class RequestQueue {
|
|
17
24
|
#queue: Array<() => Promise<unknown>> = [];
|
|
@@ -99,18 +106,17 @@ async function fetchWithRetry(
|
|
|
99
106
|
statusText: response.statusText,
|
|
100
107
|
attempt: attempt + 1,
|
|
101
108
|
maxAttempts,
|
|
102
|
-
|
|
109
|
+
body: options.body,
|
|
103
110
|
sequenceId: (options.headers as any)?.['sequence-id'],
|
|
104
111
|
};
|
|
105
112
|
|
|
106
|
-
|
|
113
|
+
logger.error('Server error, will retry:', requestInfo);
|
|
107
114
|
|
|
108
115
|
// Calculate delay with exponential backoff and jitter
|
|
109
116
|
const baseDelay = Math.min(initialDelay * Math.pow(backoffFactor, attempt), maxDelay);
|
|
110
117
|
const jitter = Math.random() * 0.1 * baseDelay; // 10% jitter
|
|
111
118
|
const delay = baseDelay + jitter;
|
|
112
119
|
|
|
113
|
-
console.log(\`[FakeClient] Retrying in \${Math.round(delay)}ms...\`);
|
|
114
120
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
115
121
|
continue;
|
|
116
122
|
}
|
|
@@ -141,11 +147,11 @@ async function fetchWithRetry(
|
|
|
141
147
|
error: error instanceof Error ? error.message : String(error),
|
|
142
148
|
attempt: attempt + 1,
|
|
143
149
|
maxAttempts,
|
|
144
|
-
|
|
150
|
+
body: options.body,
|
|
145
151
|
sequenceId: (options.headers as any)?.['sequence-id'],
|
|
146
152
|
};
|
|
147
153
|
|
|
148
|
-
|
|
154
|
+
logger.error('Request failed:', requestInfo);
|
|
149
155
|
|
|
150
156
|
if (shouldRetry && attempt < maxAttempts - 1) {
|
|
151
157
|
// Calculate delay with exponential backoff and jitter
|
|
@@ -153,7 +159,6 @@ async function fetchWithRetry(
|
|
|
153
159
|
const jitter = Math.random() * 0.1 * baseDelay; // 10% jitter
|
|
154
160
|
const delay = baseDelay + jitter;
|
|
155
161
|
|
|
156
|
-
console.log(\`[FakeClient] Retrying in \${Math.round(delay)}ms...\`);
|
|
157
162
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
158
163
|
continue;
|
|
159
164
|
}
|