Skip to content

Commit 64c2c10

Browse files
authored
graphql-request: make variables parameter optional in defaultWrapper (#559)
1 parent ad8258c commit 64c2c10

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

.changeset/flat-bulldogs-do.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/typescript-graphql-request': patch
3+
---
4+
5+
Fix unused parameter in generated code which caused TS errors for users of the package.

packages/plugins/typescript/graphql-request/src/visitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor<
155155

156156
return `${additionalExportedTypes}
157157
158-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
158+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
159159
${extraVariables.join('\n')}
160160
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
161161
return {

packages/plugins/typescript/graphql-request/tests/__snapshots__/graphql-request.spec.ts.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export const Feed4Document = \`
241241
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
242242

243243

244-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
244+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
245245

246246
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
247247
return {
@@ -527,7 +527,7 @@ export const Feed4Document = gql\`
527527
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
528528

529529

530-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
530+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
531531

532532
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
533533
return {
@@ -805,7 +805,7 @@ export const Feed4Document = \`
805805
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
806806

807807

808-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
808+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
809809

810810
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
811811
return {
@@ -1085,7 +1085,7 @@ export const Feed4Document = gql\`
10851085
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
10861086

10871087

1088-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
1088+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
10891089
const FeedDocumentString = print(FeedDocument);
10901090
const Feed2DocumentString = print(Feed2Document);
10911091
const Feed3DocumentString = print(Feed3Document);
@@ -1368,7 +1368,7 @@ export const Feed4Document = \`
13681368
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
13691369

13701370

1371-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
1371+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
13721372

13731373
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
13741374
return {
@@ -1648,7 +1648,7 @@ export const Feed4Document = gql\`
16481648
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
16491649

16501650

1651-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
1651+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
16521652

16531653
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
16541654
return {
@@ -1929,7 +1929,7 @@ export const Feed4Document = gql\`
19291929
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
19301930

19311931

1932-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
1932+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
19331933
const FeedDocumentString = print(FeedDocument);
19341934
const Feed2DocumentString = print(Feed2Document);
19351935
const Feed3DocumentString = print(Feed3Document);
@@ -2213,7 +2213,7 @@ export const Feed4Document = gql\`
22132213
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
22142214

22152215

2216-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
2216+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
22172217
const FeedDocumentString = print(FeedDocument);
22182218
const Feed2DocumentString = print(Feed2Document);
22192219
const Feed3DocumentString = print(Feed3Document);
@@ -2496,7 +2496,7 @@ export const Feed4Document = gql\`
24962496
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
24972497

24982498

2499-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
2499+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
25002500

25012501
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
25022502
return {
@@ -2776,7 +2776,7 @@ export const Feed4Document = gql\`
27762776
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
27772777

27782778

2779-
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, variables) => action();
2779+
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
27802780

27812781
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
27822782
return {

0 commit comments

Comments
 (0)