From 4cea5ddbcf61e7bb9054d51bf16f397ed635124e Mon Sep 17 00:00:00 2001 From: Alex Zhang Date: Mon, 1 Aug 2022 12:49:17 -0700 Subject: [PATCH] Add TRawResponse type to ClientQuery Summary: Add TRawResponse type to ClientQuery In D38199301 I have a query like this with `raw_response_type` because I want to use it with `commitPayload` and get the raw response type to populate the local client state initially: ``` const QUERY = graphql` query PMTCalibrationV3ContainerQuery fb_owner(oncall: "people_performance") raw_response_type { pmt_client_state { calibration_state { show_confidential_information } } } `; const INITIAL_DATA: PMTCalibrationV3ContainerQuery$rawResponse = { pmt_client_state: {calibration_state: {show_confidential_information: false}}, }; environment.commitPayload(OPERATION, INITIAL_DATA); ``` However this leads to the following generated code in `PMTCalibrationV3ContainerQuery.graphql.js` which is invalid: ``` module.exports = ((node/*: any*/)/*: ClientQuery< PMTCalibrationV3ContainerQuery$variables, PMTCalibrationV3ContainerQuery$data, PMTCalibrationV3ContainerQuery$rawResponse, >*/); ``` I'm just matching the definition of the regular `Query` and hoping this is safe to do, since it doesn't seem like it actually does anything type checking wise Reviewed By: alunyov Differential Revision: D38293946 fbshipit-source-id: 7b56384b8bbd0cad5d261fab0ef41acd7ea87718 --- packages/relay-runtime/util/RelayRuntimeTypes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/relay-runtime/util/RelayRuntimeTypes.js b/packages/relay-runtime/util/RelayRuntimeTypes.js index 1d9ef9fecdaf8..3a0ab6a2cc0ac 100644 --- a/packages/relay-runtime/util/RelayRuntimeTypes.js +++ b/packages/relay-runtime/util/RelayRuntimeTypes.js @@ -117,6 +117,7 @@ declare export opaque type Query< declare export opaque type ClientQuery< -TVariables: Variables, +TData, + TRawResponse = void, >: ClientRequest; /**