@graphql-hive/core 0.19.0-alpha-20251219094156-5fea82e5465260f0a55cc2c82a16c3fd36e74a51 → 0.19.0-alpha-20251219111139-af6444ea77e24f442bc8f02022cd0d0312d9fea1

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.
@@ -276,19 +276,33 @@ function createCollector({ schema, max, ttl, processVariables = false, }) {
276
276
  return (0, utils_js_1.cacheDocumentKey)(doc, processVariables === true ? variables : null);
277
277
  }, (0, tiny_lru_1.default)(max, ttl));
278
278
  }
279
- const defaultClientNameHeader = 'x-graphql-client-name';
280
- const defaultClientVersionHeader = 'x-graphql-client-version';
279
+ const defaultClientNameHeaders = ['x-graphql-client-name', 'graphql-client-name'];
280
+ const defaultClientVersionHeaders = ['x-graphql-client-version', 'graphql-client-version'];
281
+ function lookupHeader(headerGetter, possibleNames) {
282
+ for (const name of possibleNames) {
283
+ const value = headerGetter(name);
284
+ if (typeof value === 'string') {
285
+ return value;
286
+ }
287
+ }
288
+ return null;
289
+ }
281
290
  function createDefaultClientInfo(config) {
282
- var _a, _b, _c, _d, _e, _f;
283
- const clientNameHeader = (_b = (_a = config === null || config === void 0 ? void 0 : config.http) === null || _a === void 0 ? void 0 : _a.clientHeaderName) !== null && _b !== void 0 ? _b : defaultClientNameHeader;
284
- const clientVersionHeader = (_d = (_c = config === null || config === void 0 ? void 0 : config.http) === null || _c === void 0 ? void 0 : _c.versionHeaderName) !== null && _d !== void 0 ? _d : defaultClientVersionHeader;
285
- const clientFieldName = (_f = (_e = config === null || config === void 0 ? void 0 : config.ws) === null || _e === void 0 ? void 0 : _e.clientFieldName) !== null && _f !== void 0 ? _f : 'client';
291
+ var _a, _b, _c, _d;
292
+ const clientNameHeaders = new Set(((_a = config === null || config === void 0 ? void 0 : config.http) === null || _a === void 0 ? void 0 : _a.clientHeaderName)
293
+ ? [config.http.clientHeaderName, ...defaultClientNameHeaders]
294
+ : defaultClientNameHeaders);
295
+ const clientVersionHeaders = new Set(((_b = config === null || config === void 0 ? void 0 : config.http) === null || _b === void 0 ? void 0 : _b.versionHeaderName)
296
+ ? [config.http.versionHeaderName, ...defaultClientVersionHeaders]
297
+ : defaultClientVersionHeaders);
298
+ const clientFieldName = (_d = (_c = config === null || config === void 0 ? void 0 : config.ws) === null || _c === void 0 ? void 0 : _c.clientFieldName) !== null && _d !== void 0 ? _d : 'client';
286
299
  return function defaultClientInfo(context) {
287
- var _a, _b, _c, _d, _e, _f, _g;
300
+ var _a, _b, _c, _d, _e, _f;
288
301
  // whatwg Request
289
302
  if (typeof ((_b = (_a = context === null || context === void 0 ? void 0 : context.request) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.get) === 'function') {
290
- const name = context.request.headers.get(clientNameHeader);
291
- const version = context.request.headers.get(clientVersionHeader);
303
+ const headerGetter = (name) => { var _a, _b; return (_b = (_a = context === null || context === void 0 ? void 0 : context.request) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.get(name); };
304
+ const name = lookupHeader(headerGetter, clientNameHeaders);
305
+ const version = lookupHeader(headerGetter, clientVersionHeaders);
292
306
  if (typeof name === 'string' && typeof version === 'string') {
293
307
  return {
294
308
  name,
@@ -299,8 +313,9 @@ function createDefaultClientInfo(config) {
299
313
  }
300
314
  // Node.js IncomingMessage
301
315
  if (((_c = context === null || context === void 0 ? void 0 : context.req) === null || _c === void 0 ? void 0 : _c.headers) && typeof ((_d = context.req) === null || _d === void 0 ? void 0 : _d.headers) === 'object') {
302
- const name = context.req.headers[clientNameHeader];
303
- const version = context.req.headers[clientVersionHeader];
316
+ const headerGetter = (name) => context.req.headers[name];
317
+ const name = lookupHeader(headerGetter, clientNameHeaders);
318
+ const version = lookupHeader(headerGetter, clientVersionHeaders);
304
319
  if (typeof name === 'string' && typeof version === 'string') {
305
320
  return {
306
321
  name,
@@ -310,9 +325,10 @@ function createDefaultClientInfo(config) {
310
325
  return null;
311
326
  }
312
327
  // Plain headers object
313
- if ((context === null || context === void 0 ? void 0 : context.headers) && typeof ((_e = context.req) === null || _e === void 0 ? void 0 : _e.headers) === 'object') {
314
- const name = context.req.headers[clientNameHeader];
315
- const version = context.req.headers[clientVersionHeader];
328
+ if ((context === null || context === void 0 ? void 0 : context.headers) && typeof context.headers === 'object') {
329
+ const headerGetter = (name) => context.headers[name];
330
+ const name = lookupHeader(headerGetter, clientNameHeaders);
331
+ const version = lookupHeader(headerGetter, clientVersionHeaders);
316
332
  if (typeof name === 'string' && typeof version === 'string') {
317
333
  return {
318
334
  name,
@@ -322,8 +338,8 @@ function createDefaultClientInfo(config) {
322
338
  return null;
323
339
  }
324
340
  // GraphQL over WebSocket
325
- if (((_f = context === null || context === void 0 ? void 0 : context.connectionParams) === null || _f === void 0 ? void 0 : _f[clientFieldName]) &&
326
- typeof ((_g = context.connectionParams) === null || _g === void 0 ? void 0 : _g[clientFieldName]) === 'object') {
341
+ if (((_e = context === null || context === void 0 ? void 0 : context.connectionParams) === null || _e === void 0 ? void 0 : _e[clientFieldName]) &&
342
+ typeof ((_f = context.connectionParams) === null || _f === void 0 ? void 0 : _f[clientFieldName]) === 'object') {
327
343
  const name = context.connectionParams[clientFieldName].name;
328
344
  const version = context.connectionParams[clientFieldName].version;
329
345
  if (typeof name === 'string' && typeof version === 'string') {
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.19.0-alpha-20251219094156-5fea82e5465260f0a55cc2c82a16c3fd36e74a51';
4
+ exports.version = '0.19.0-alpha-20251219111139-af6444ea77e24f442bc8f02022cd0d0312d9fea1';
@@ -271,19 +271,33 @@ export function createCollector({ schema, max, ttl, processVariables = false, })
271
271
  return cacheDocumentKey(doc, processVariables === true ? variables : null);
272
272
  }, LRU(max, ttl));
273
273
  }
274
- const defaultClientNameHeader = 'x-graphql-client-name';
275
- const defaultClientVersionHeader = 'x-graphql-client-version';
274
+ const defaultClientNameHeaders = ['x-graphql-client-name', 'graphql-client-name'];
275
+ const defaultClientVersionHeaders = ['x-graphql-client-version', 'graphql-client-version'];
276
+ function lookupHeader(headerGetter, possibleNames) {
277
+ for (const name of possibleNames) {
278
+ const value = headerGetter(name);
279
+ if (typeof value === 'string') {
280
+ return value;
281
+ }
282
+ }
283
+ return null;
284
+ }
276
285
  function createDefaultClientInfo(config) {
277
- var _a, _b, _c, _d, _e, _f;
278
- const clientNameHeader = (_b = (_a = config === null || config === void 0 ? void 0 : config.http) === null || _a === void 0 ? void 0 : _a.clientHeaderName) !== null && _b !== void 0 ? _b : defaultClientNameHeader;
279
- const clientVersionHeader = (_d = (_c = config === null || config === void 0 ? void 0 : config.http) === null || _c === void 0 ? void 0 : _c.versionHeaderName) !== null && _d !== void 0 ? _d : defaultClientVersionHeader;
280
- const clientFieldName = (_f = (_e = config === null || config === void 0 ? void 0 : config.ws) === null || _e === void 0 ? void 0 : _e.clientFieldName) !== null && _f !== void 0 ? _f : 'client';
286
+ var _a, _b, _c, _d;
287
+ const clientNameHeaders = new Set(((_a = config === null || config === void 0 ? void 0 : config.http) === null || _a === void 0 ? void 0 : _a.clientHeaderName)
288
+ ? [config.http.clientHeaderName, ...defaultClientNameHeaders]
289
+ : defaultClientNameHeaders);
290
+ const clientVersionHeaders = new Set(((_b = config === null || config === void 0 ? void 0 : config.http) === null || _b === void 0 ? void 0 : _b.versionHeaderName)
291
+ ? [config.http.versionHeaderName, ...defaultClientVersionHeaders]
292
+ : defaultClientVersionHeaders);
293
+ const clientFieldName = (_d = (_c = config === null || config === void 0 ? void 0 : config.ws) === null || _c === void 0 ? void 0 : _c.clientFieldName) !== null && _d !== void 0 ? _d : 'client';
281
294
  return function defaultClientInfo(context) {
282
- var _a, _b, _c, _d, _e, _f, _g;
295
+ var _a, _b, _c, _d, _e, _f;
283
296
  // whatwg Request
284
297
  if (typeof ((_b = (_a = context === null || context === void 0 ? void 0 : context.request) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.get) === 'function') {
285
- const name = context.request.headers.get(clientNameHeader);
286
- const version = context.request.headers.get(clientVersionHeader);
298
+ const headerGetter = (name) => { var _a, _b; return (_b = (_a = context === null || context === void 0 ? void 0 : context.request) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.get(name); };
299
+ const name = lookupHeader(headerGetter, clientNameHeaders);
300
+ const version = lookupHeader(headerGetter, clientVersionHeaders);
287
301
  if (typeof name === 'string' && typeof version === 'string') {
288
302
  return {
289
303
  name,
@@ -294,8 +308,9 @@ function createDefaultClientInfo(config) {
294
308
  }
295
309
  // Node.js IncomingMessage
296
310
  if (((_c = context === null || context === void 0 ? void 0 : context.req) === null || _c === void 0 ? void 0 : _c.headers) && typeof ((_d = context.req) === null || _d === void 0 ? void 0 : _d.headers) === 'object') {
297
- const name = context.req.headers[clientNameHeader];
298
- const version = context.req.headers[clientVersionHeader];
311
+ const headerGetter = (name) => context.req.headers[name];
312
+ const name = lookupHeader(headerGetter, clientNameHeaders);
313
+ const version = lookupHeader(headerGetter, clientVersionHeaders);
299
314
  if (typeof name === 'string' && typeof version === 'string') {
300
315
  return {
301
316
  name,
@@ -305,9 +320,10 @@ function createDefaultClientInfo(config) {
305
320
  return null;
306
321
  }
307
322
  // Plain headers object
308
- if ((context === null || context === void 0 ? void 0 : context.headers) && typeof ((_e = context.req) === null || _e === void 0 ? void 0 : _e.headers) === 'object') {
309
- const name = context.req.headers[clientNameHeader];
310
- const version = context.req.headers[clientVersionHeader];
323
+ if ((context === null || context === void 0 ? void 0 : context.headers) && typeof context.headers === 'object') {
324
+ const headerGetter = (name) => context.headers[name];
325
+ const name = lookupHeader(headerGetter, clientNameHeaders);
326
+ const version = lookupHeader(headerGetter, clientVersionHeaders);
311
327
  if (typeof name === 'string' && typeof version === 'string') {
312
328
  return {
313
329
  name,
@@ -317,8 +333,8 @@ function createDefaultClientInfo(config) {
317
333
  return null;
318
334
  }
319
335
  // GraphQL over WebSocket
320
- if (((_f = context === null || context === void 0 ? void 0 : context.connectionParams) === null || _f === void 0 ? void 0 : _f[clientFieldName]) &&
321
- typeof ((_g = context.connectionParams) === null || _g === void 0 ? void 0 : _g[clientFieldName]) === 'object') {
336
+ if (((_e = context === null || context === void 0 ? void 0 : context.connectionParams) === null || _e === void 0 ? void 0 : _e[clientFieldName]) &&
337
+ typeof ((_f = context.connectionParams) === null || _f === void 0 ? void 0 : _f[clientFieldName]) === 'object') {
322
338
  const name = context.connectionParams[clientFieldName].name;
323
339
  const version = context.connectionParams[clientFieldName].version;
324
340
  if (typeof name === 'string' && typeof version === 'string') {
package/esm/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '0.19.0-alpha-20251219094156-5fea82e5465260f0a55cc2c82a16c3fd36e74a51';
1
+ export const version = '0.19.0-alpha-20251219111139-af6444ea77e24f442bc8f02022cd0d0312d9fea1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/core",
3
- "version": "0.19.0-alpha-20251219094156-5fea82e5465260f0a55cc2c82a16c3fd36e74a51",
3
+ "version": "0.19.0-alpha-20251219111139-af6444ea77e24f442bc8f02022cd0d0312d9fea1",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
@@ -1,2 +1,2 @@
1
- export declare const version = "0.19.0-alpha-20251219094156-5fea82e5465260f0a55cc2c82a16c3fd36e74a51";
1
+ export declare const version = "0.19.0-alpha-20251219111139-af6444ea77e24f442bc8f02022cd0d0312d9fea1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const version = "0.19.0-alpha-20251219094156-5fea82e5465260f0a55cc2c82a16c3fd36e74a51";
1
+ export declare const version = "0.19.0-alpha-20251219111139-af6444ea77e24f442bc8f02022cd0d0312d9fea1";
2
2
  //# sourceMappingURL=version.d.ts.map