mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 00:58:36 +00:00
fix: client info sanitisation (#4932)
This commit is contained in:
parent
8065e48bce
commit
cbc836488b
2 changed files with 19 additions and 2 deletions
6
.changeset/clean-cameras-compete.md
Normal file
6
.changeset/clean-cameras-compete.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@graphql-hive/core': patch
|
||||
---
|
||||
|
||||
Prevent failing usage reporting when returning an object with additional properties aside from
|
||||
`name` and `version` from the client info object/factory function.
|
||||
|
|
@ -215,11 +215,12 @@ export function createUsage(pluginOptions: HivePluginOptions): UsageCollector {
|
|||
errors,
|
||||
},
|
||||
// TODO: operationHash is ready to accept hashes of persisted operations
|
||||
client:
|
||||
client: pickClientInfoProperties(
|
||||
typeof args.contextValue !== 'undefined' &&
|
||||
typeof options.clientInfo !== 'undefined'
|
||||
typeof options.clientInfo !== 'undefined'
|
||||
? options.clientInfo(args.contextValue)
|
||||
: createDefaultClientInfo()(args.contextValue),
|
||||
),
|
||||
},
|
||||
};
|
||||
}),
|
||||
|
|
@ -501,3 +502,13 @@ function createDefaultClientInfo(
|
|||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
function pickClientInfoProperties(info: null | undefined | ClientInfo): null | ClientInfo {
|
||||
if (!info) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
name: info.name,
|
||||
version: info.version,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue