@@ -4,6 +4,8 @@ import type {
44 EndpointInterface ,
55} from "@octokit/types" ;
66
7+ import type { DocumentTypeDecoration } from "@graphql-typed-document-node/core" ;
8+
79import type { graphql } from "./graphql.js" ;
810
911export type GraphQlEndpointOptions = EndpointOptions & {
@@ -33,6 +35,25 @@ export interface graphql {
3335 parameters ?: RequestParameters ,
3436 ) : GraphQlResponse < ResponseData > ;
3537
38+ /**
39+ * Sends a GraphQL query request based on endpoint options. The query parameters are type-checked
40+ *
41+ * @param {String & DocumentTypeDecoration<ResponseData, QueryVariables> } query GraphQL query. Example: `'query { viewer { login } }'`.
42+ * @param {object } [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
43+ */
44+ < ResponseData , QueryVariables > (
45+ query : String & DocumentTypeDecoration < ResponseData , QueryVariables > ,
46+ /**
47+ * The tuple in rest parameters allows makes RequestParameters conditionally
48+ * optional , if the query does not require any variables.
49+ *
50+ * @see https://github.com/Microsoft/TypeScript/pull/24897#:~:text=not%20otherwise%20observable).-,Optional%20elements%20in%20tuple%20types,-Tuple%20types%20now
51+ */
52+ ...[ parameters ] : QueryVariables extends Record < string , never >
53+ ? [ RequestParameters ?]
54+ : [ QueryVariables & RequestParameters ]
55+ ) : GraphQlResponse < ResponseData > ;
56+
3657 /**
3758 * Returns a new `endpoint` with updated route and parameters
3859 */
0 commit comments