Open voideanvalue opened 2 years ago
I have a TODO somewhere to rename requiredFieldLogger
. It's on my list. We also need to update the types (Flow and Typescript) to make that logger non-optional.
CC @tbezman: Heads up about the module resolution issue with Resolvers and default exports.
we got this error
Relay Environment Configuration Error (dev only): `@required(action: LOG)` requires that the Relay Environment be configured with a `requiredFieldLogger`.
at RelayModernEnvironment.defaultRequiredFieldLogger [as requiredFieldLogger]
is this related ?
@sibelius I think that's different... it's saying that @required(action: LOG)
is being used but the RelayEnvironment
instance you're using doesn't have requiredFieldLogger
configured
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 realizedrequiredFieldLogger
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 viarequiredFieldLogger
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...
andresolverModule: require('...')
not playing well together. We don't attempt to unwrap default anywhere inRelayReader
. We do inloadEntryPoint
andGraphQLTag
... probably worth having a utility function somewhere to share across all three and any future places we load modules.