Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 1ea774a

Browse files
committed
add extensions to GraphQLParams
1 parent 7e33e77 commit 1ea774a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

packages/core/src/get-graphql-parameters.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@ import type { GraphQLParams, Request } from "./types";
44
export const getGraphQLParameters = (request: Request): GraphQLParams => {
55
const { body, method, query: queryParams } = request;
66

7-
let operationName;
8-
let query;
9-
let variables;
7+
let operationName: GraphQLParams["operationName"];
8+
let query: GraphQLParams["query"];
9+
let variables: GraphQLParams["variables"];
10+
let extensions: GraphQLParams["extensions"];
1011

1112
if (isHttpMethod("GET", method)) {
1213
operationName = queryParams.operationName;
1314
query = queryParams.query;
1415
variables = queryParams.variables;
15-
} else if (isHttpMethod("POST", method)) {
16-
operationName = body?.operationName;
17-
query = body?.query;
18-
variables = body?.variables;
16+
extensions = queryParams.extensions;
17+
} else if (isHttpMethod("POST", method) && body) {
18+
operationName = body.operationName;
19+
query = body.query;
20+
variables = body.variables;
21+
extensions = body.extensions;
1922
}
2023

2124
return {
2225
operationName,
2326
query,
2427
variables,
28+
extensions,
2529
};
2630
};

packages/core/src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface GraphQLParams {
2323
operationName?: string;
2424
query?: string;
2525
variables?: string | { [name: string]: any };
26+
extensions?: string | Record<string, unknown>;
2627
}
2728

2829
export interface ProcessRequestOptions<TContext, TRootValue> {
@@ -84,6 +85,10 @@ export interface ProcessRequestOptions<TContext, TRootValue> {
8485
* Values for any Variables defined by the Operation.
8586
*/
8687
variables?: string | { [name: string]: any };
88+
/**
89+
* Extensions specified in request
90+
*/
91+
extensions?: string | Record<string, unknown>;
8792
}
8893

8994
export interface FormatPayloadParams<TContext, TRootValue> {

0 commit comments

Comments
 (0)