Skip to content

Commit

Permalink
Add TRawResponse type to ClientQuery
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Alex Zhang authored and facebook-github-bot committed Aug 1, 2022
1 parent 0530b34 commit 4cea5dd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/relay-runtime/util/RelayRuntimeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ declare export opaque type Query<
declare export opaque type ClientQuery<
-TVariables: Variables,
+TData,
TRawResponse = void,
>: ClientRequest;

/**
Expand Down

0 comments on commit 4cea5dd

Please sign in to comment.