[Relay 18] Relay Resolver return type not getting derived from resolver function
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
# Creating issues for Relay
## Questions regarding how to use Relay and/or GraphQL
We are experimenting with Relay 18 and have noticed that the return type of a Relay resolver with `RelayResolverValue` is no longer being derived in the generated TypeScript type definition
For example:
Given the following relay resolver implementation
```ts
type ContactInfo = {
address: string;
phone: string;
};
/**
* @RelayResolver PersonalDetails.contactInfo: RelayResolverValue
*/
export function contactInfo(personalDetailsRef: RelayResolversPostalCodeFragment$key): ContactInfo {
const data = readFragment(
graphql`
fragment RelayResolversPostalCodeFragment on PersonalDetails {
address
phone
}
`,
personalDetailsRef,
);
// a very dummy example
return {...data}
}
```
In the generated relay artifact that references the `contactInfo`
```ts
import { ConcreteRequest, Query } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
// This is missing in Relay 18
// import { contactInfo as personalDetailsContactInfoResolverType } from "../RelayResolvers";
export type RelayResolversComplexRequiredThrowQuery$variables = Record;
export type RelayResolversComplexRequiredThrowQuery$data = {
readonly viewer: {
readonly userProperties: {
readonly personalDetails: {
readonly contactInfo: ReturnType | null;
} | null;
};
};
};
```
Relay used to derive the return type `import { contactInfo as personalDetailsContactInfoResolverType } from "../RelayResolvers";`, but this is now missing in Relay 18
Appreciate any insights. Thanks
## Reporting issues with Relay
We will be using GitHub Issues for our public bugs. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new issue, make sure an issue for your problem doesn't already exist.
The best way to get your bug fixed is to provide a reduced test case. To make reproduction simple for you, and set-up simple for Relay's maintainers, you can use Glitch:
https://glitch.com/edit/#!/remix/relay-starter-kit
You can also provide a public repository with a runnable example.
## Security bugs
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page.
Contributor guide
Assessment
This issue has not been assessed yet.