Skip to content

Commit

Permalink
fix(graphql-request): use Headers in return type (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
yshrsmz authored Jul 8, 2023
1 parent 6a13cbc commit cb57636
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-monkeys-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/typescript-graphql-request': patch
---

fix(graphql-request): use Headers in return type when rawRequest is true
2 changes: 1 addition & 1 deletion packages/plugins/typescript/graphql-request/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor<
o.operationVariablesTypes
}, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: ${
o.operationResultType
}; extensions?: ${this.config.extensionsType}; headers: Dom.Headers; status: number; }> {
}; extensions?: ${this.config.extensionsType}; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<${
o.operationResultType
}>(${docArg}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1092,16 +1092,16 @@ const Feed3DocumentString = print(Feed3Document);
const Feed4DocumentString = print(Feed4Document);
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
return {
feed(variables?: FeedQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: FeedQuery; extensions?: any; headers: Dom.Headers; status: number; }> {
feed(variables?: FeedQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: FeedQuery; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<FeedQuery>(FeedDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed', 'query');
},
feed2(variables: Feed2QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed2Query; extensions?: any; headers: Dom.Headers; status: number; }> {
feed2(variables: Feed2QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed2Query; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed2Query>(Feed2DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed2', 'query');
},
feed3(variables?: Feed3QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed3Query; extensions?: any; headers: Dom.Headers; status: number; }> {
feed3(variables?: Feed3QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed3Query; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed3Query>(Feed3DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed3', 'query');
},
feed4(variables?: Feed4QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed4Query; extensions?: any; headers: Dom.Headers; status: number; }> {
feed4(variables?: Feed4QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed4Query; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed4Query>(Feed4DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed4', 'query');
}
};
Expand Down Expand Up @@ -1656,16 +1656,16 @@ const Feed3DocumentString = print(Feed3Document);
const Feed4DocumentString = print(Feed4Document);
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
return {
feed(variables?: FeedQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: FeedQuery; extensions?: unknown; headers: Dom.Headers; status: number; }> {
feed(variables?: FeedQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: FeedQuery; extensions?: unknown; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<FeedQuery>(FeedDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed', 'query');
},
feed2(variables: Feed2QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed2Query; extensions?: unknown; headers: Dom.Headers; status: number; }> {
feed2(variables: Feed2QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed2Query; extensions?: unknown; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed2Query>(Feed2DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed2', 'query');
},
feed3(variables?: Feed3QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed3Query; extensions?: unknown; headers: Dom.Headers; status: number; }> {
feed3(variables?: Feed3QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed3Query; extensions?: unknown; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed3Query>(Feed3DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed3', 'query');
},
feed4(variables?: Feed4QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed4Query; extensions?: unknown; headers: Dom.Headers; status: number; }> {
feed4(variables?: Feed4QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed4Query; extensions?: unknown; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed4Query>(Feed4DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed4', 'query');
}
};
Expand Down Expand Up @@ -1940,16 +1940,16 @@ const Feed3DocumentString = print(Feed3Document);
const Feed4DocumentString = print(Feed4Document);
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
return {
feed(variables?: FeedQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: FeedQuery; extensions?: any; headers: Dom.Headers; status: number; }> {
feed(variables?: FeedQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: FeedQuery; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<FeedQuery>(FeedDocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed', 'query');
},
feed2(variables: Feed2QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed2Query; extensions?: any; headers: Dom.Headers; status: number; }> {
feed2(variables: Feed2QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed2Query; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed2Query>(Feed2DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed2', 'query');
},
feed3(variables?: Feed3QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed3Query; extensions?: any; headers: Dom.Headers; status: number; }> {
feed3(variables?: Feed3QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed3Query; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed3Query>(Feed3DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed3', 'query');
},
feed4(variables?: Feed4QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed4Query; extensions?: any; headers: Dom.Headers; status: number; }> {
feed4(variables?: Feed4QueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<{ data: Feed4Query; extensions?: any; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<Feed4Query>(Feed4DocumentString, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed4', 'query');
}
};
Expand Down

0 comments on commit cb57636

Please sign in to comment.