Skip to content

Commit

Permalink
chore: remove option to set clientName and clientVersion as a static …
Browse files Browse the repository at this point in the history
…string (#3458)

Co-authored-by: Tomas Kroupa <[email protected]>
  • Loading branch information
kroupacz and Tomas Kroupa authored Nov 26, 2024
1 parent a4bc07f commit cb29c6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphql-yoga/plugin-apollo-usage-report": minor
---

### Removed
- **Breaking change** remove option to set `clientName` and `clientVersion` as a static `string` in `ApolloUsageReportOptions`
16 changes: 4 additions & 12 deletions packages/plugins/apollo-usage-report/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ type ApolloUsageReportOptions = ApolloInlineTracePluginOptions & {
/**
* Client name to report to the usage reporting API
*/
clientName?: StringFromRequestFn | string;
clientName?: StringFromRequestFn;
/**
* Client version to report to the usage reporting API
*/
clientVersion?: StringFromRequestFn | string;
clientVersion?: StringFromRequestFn;
};

export interface ApolloUsageReportRequestContext extends ApolloInlineRequestTraceContext {
Expand Down Expand Up @@ -89,21 +89,13 @@ export function useApolloUsageReport(options: ApolloUsageReportOptions = {}): Pl
) as YogaLogger;

let clientNameFactory: StringFromRequestFn = req => req.headers.get('apollographql-client-name');

if (typeof options.clientName === 'string') {
const clientName = options.clientName;
clientNameFactory = () => clientName;
} else if (typeof options.clientName === 'function') {
if (typeof options.clientName === 'function') {
clientNameFactory = options.clientName;
}

let clientVersionFactory: StringFromRequestFn = req =>
req.headers.get('apollographql-client-version');

if (typeof options.clientVersion === 'string') {
const clientVersion = options.clientVersion;
clientVersionFactory = () => clientVersion;
} else if (typeof options.clientVersion === 'function') {
if (typeof options.clientVersion === 'function') {
clientVersionFactory = options.clientVersion;
}

Expand Down

0 comments on commit cb29c6c

Please sign in to comment.