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
  • Loading branch information
Tomas Kroupa committed Nov 4, 2024
1 parent 708d908 commit a052c39
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 @@ -90,21 +90,13 @@ export function useApolloUsageReport(options: ApolloUsageReportOptions = {}): Pl

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

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') || yoga.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 a052c39

Please sign in to comment.