@graphql-hive/apollo 0.45.1-alpha-20251212115012-f9e6f24cd70db99ed5d5419def6023f461fd1fd6 → 0.46.0-alpha-20251216190557-6368165fac7bb1e1227d97eef66dce9ae04a8f53

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/cjs/index.js CHANGED
@@ -168,20 +168,40 @@ function useHive(clientOrOptions) {
168
168
  'documentId' in context.request.http.body &&
169
169
  typeof context.request.http.body.documentId === 'string') {
170
170
  persistedDocumentHash = context.request.http.body.documentId;
171
- const document = await hive.experimental__persistedDocuments.resolve(context.request.http.body.documentId);
172
- if (document) {
173
- context.request.query = document;
174
- }
175
- else {
176
- context.request.query = '{__typename}';
177
- persistedDocumentError = new graphql_1.GraphQLError('Persisted document not found.', {
178
- extensions: {
179
- code: 'PERSISTED_DOCUMENT_NOT_FOUND',
180
- http: {
181
- status: 400,
171
+ try {
172
+ const document = await hive.experimental__persistedDocuments.resolve(context.request.http.body.documentId);
173
+ if (document) {
174
+ context.request.query = document;
175
+ }
176
+ else {
177
+ // Document not found - this is also a client error (400)
178
+ context.request.query = '{__typename}';
179
+ persistedDocumentError = new graphql_1.GraphQLError('Persisted document not found.', {
180
+ extensions: {
181
+ code: 'PERSISTED_DOCUMENT_NOT_FOUND',
182
+ http: {
183
+ status: 400,
184
+ },
182
185
  },
183
- },
184
- });
186
+ });
187
+ }
188
+ }
189
+ catch (error) {
190
+ // Check if this is a client error (400-range status) - preserve the error
191
+ if ((error === null || error === void 0 ? void 0 : error.status) >= 400 && (error === null || error === void 0 ? void 0 : error.status) < 500) {
192
+ context.request.query = '{__typename}';
193
+ // Use the original error's extensions if available, otherwise create basic ones
194
+ const extensions = Object.assign(Object.assign({}, error === null || error === void 0 ? void 0 : error.extensions), { code: (error === null || error === void 0 ? void 0 : error.code) || 'CLIENT_ERROR', http: {
195
+ status: (error === null || error === void 0 ? void 0 : error.status) || 400,
196
+ } });
197
+ persistedDocumentError = new graphql_1.GraphQLError(error.message || 'Client error.', {
198
+ extensions,
199
+ });
200
+ }
201
+ else {
202
+ // Re-throw server errors (500+ status) - these should remain as server errors
203
+ throw error;
204
+ }
185
205
  }
186
206
  }
187
207
  else if (false ===
package/cjs/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = '0.45.1-alpha-20251212115012-f9e6f24cd70db99ed5d5419def6023f461fd1fd6';
4
+ exports.version = '0.46.0-alpha-20251216190557-6368165fac7bb1e1227d97eef66dce9ae04a8f53';
package/esm/index.js CHANGED
@@ -158,20 +158,40 @@ export function useHive(clientOrOptions) {
158
158
  'documentId' in context.request.http.body &&
159
159
  typeof context.request.http.body.documentId === 'string') {
160
160
  persistedDocumentHash = context.request.http.body.documentId;
161
- const document = await hive.experimental__persistedDocuments.resolve(context.request.http.body.documentId);
162
- if (document) {
163
- context.request.query = document;
164
- }
165
- else {
166
- context.request.query = '{__typename}';
167
- persistedDocumentError = new GraphQLError('Persisted document not found.', {
168
- extensions: {
169
- code: 'PERSISTED_DOCUMENT_NOT_FOUND',
170
- http: {
171
- status: 400,
161
+ try {
162
+ const document = await hive.experimental__persistedDocuments.resolve(context.request.http.body.documentId);
163
+ if (document) {
164
+ context.request.query = document;
165
+ }
166
+ else {
167
+ // Document not found - this is also a client error (400)
168
+ context.request.query = '{__typename}';
169
+ persistedDocumentError = new GraphQLError('Persisted document not found.', {
170
+ extensions: {
171
+ code: 'PERSISTED_DOCUMENT_NOT_FOUND',
172
+ http: {
173
+ status: 400,
174
+ },
172
175
  },
173
- },
174
- });
176
+ });
177
+ }
178
+ }
179
+ catch (error) {
180
+ // Check if this is a client error (400-range status) - preserve the error
181
+ if ((error === null || error === void 0 ? void 0 : error.status) >= 400 && (error === null || error === void 0 ? void 0 : error.status) < 500) {
182
+ context.request.query = '{__typename}';
183
+ // Use the original error's extensions if available, otherwise create basic ones
184
+ const extensions = Object.assign(Object.assign({}, error === null || error === void 0 ? void 0 : error.extensions), { code: (error === null || error === void 0 ? void 0 : error.code) || 'CLIENT_ERROR', http: {
185
+ status: (error === null || error === void 0 ? void 0 : error.status) || 400,
186
+ } });
187
+ persistedDocumentError = new GraphQLError(error.message || 'Client error.', {
188
+ extensions,
189
+ });
190
+ }
191
+ else {
192
+ // Re-throw server errors (500+ status) - these should remain as server errors
193
+ throw error;
194
+ }
175
195
  }
176
196
  }
177
197
  else if (false ===
package/esm/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '0.45.1-alpha-20251212115012-f9e6f24cd70db99ed5d5419def6023f461fd1fd6';
1
+ export const version = '0.46.0-alpha-20251216190557-6368165fac7bb1e1227d97eef66dce9ae04a8f53';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/apollo",
3
- "version": "0.45.1-alpha-20251212115012-f9e6f24cd70db99ed5d5419def6023f461fd1fd6",
3
+ "version": "0.46.0-alpha-20251216190557-6368165fac7bb1e1227d97eef66dce9ae04a8f53",
4
4
  "description": "GraphQL Hive + Apollo Server",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@graphql-hive/logger": "^1.0.9",
12
- "@graphql-hive/core": "0.18.1-alpha-20251212115012-f9e6f24cd70db99ed5d5419def6023f461fd1fd6"
12
+ "@graphql-hive/core": "0.19.0-alpha-20251216190557-6368165fac7bb1e1227d97eef66dce9ae04a8f53"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -1,2 +1,2 @@
1
- export declare const version = "0.45.1-alpha-20251212115012-f9e6f24cd70db99ed5d5419def6023f461fd1fd6";
1
+ export declare const version = "0.46.0-alpha-20251216190557-6368165fac7bb1e1227d97eef66dce9ae04a8f53";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const version = "0.45.1-alpha-20251212115012-f9e6f24cd70db99ed5d5419def6023f461fd1fd6";
1
+ export declare const version = "0.46.0-alpha-20251216190557-6368165fac7bb1e1227d97eef66dce9ae04a8f53";
2
2
  //# sourceMappingURL=version.d.ts.map