facebook / facebook/relay

Relay Resolvers named imports consistency

Open
#4,117 2 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

Love the progress on resolvers - looks like they'll open up a lot of options for us.

With `use_named_imports_for_relay_resolvers` enabled....

1. There's nothing checking that the field name you use matches the exported function name, which leads to importing names that don't exist
```ts
/**
* @RelayResolver Query.example: String
*/
export function other(){}
```
```js
import { example as ... } from ...
// should instead be
import { other as ... } from ...
```
But this should probably be a validation error.

2. There's potential accidentally use a `default export`, even though `use_named_imports_for_relay_resolvers` switched the behaviour
```
/**
* @RelayResolver Query.example: String
*/
export default function example(){}
```
```
import { example as ... } from ...
```
But `example` wasn't exported. This should also be a validation error.

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementation of use_named_imports_for_relay_resolvers and the resolver validation or import-generation tests. Trace how the RelayResolver field name maps to an exported function, including default exports. Done means mismatched names and default exports produce validation errors instead of invalid named imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.