facebook / facebook/relay

improve reporting resolver failures

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

Description

I was trying to introduce resolvers to `relayjs/relay-examples` (in the nextjs example, manually hacked around the haste style requires printed by the compiler). I couldn't figure out why things weren't working for the longest time. The resolver module factory was getting executed but the resolver function didn't. Noting down some thoughts here for future me.

* `__log` provided to environment didn't show anything. I later realized `requiredFieldLogger` reports it but I totally didn't consider using it before I understood why the resolver wasn't getting invoked (in fact, that's when I remembered us talking about reporting resolver errors via `requiredFieldLogger` in the past). `requiredFieldLogger` probably needs a rename. maybe worth thinking about reporting/logging interface more broadly too.

* I eventually figured out that the issue was caused by `export default function MyResolver...` and `resolverModule: require('...')` not playing well together. We don't attempt to unwrap default anywhere in `RelayReader`. We do in `loadEntryPoint` and `GraphQLTag`... probably worth having a utility function somewhere to share across all three and any future places we load modules.

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.