facebook / facebook/relay

Add $variables to ConcreteRequest

Open
#3,911 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Relay generates files from default node export of type `ConcreteRequest`.

There is also a separate type export `$variables`:

```
export type IndependentPaidProjectPageQuery$variables = {
id: string;
};
```

However, it seems that `ConcreteRequest` has all the necessary data to infer `$variables`:

```
> JSON.stringify(node.operation.argumentDefinitions)
< '[{"defaultValue":null,"kind":"LocalArgument","name":"id"}]'
```

Is there a way to infer `$variables` just from `ConcreteRequest` using TypeScript?

Being able to infer using a helper (or updating relay output to add `$variables` to `ConcreteRequest`) would reduce the need to import individual types, e.g. our route exports `ConcreteRequest`, which I would then like to use to infer what parameters to route loader needs to have – at the moment, the only way to do it is by separately importing `IndependentPaidProjectPageQuery$variables`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.