Skip to main content
Version: Next 🚧

Enabling Relay Resolvers

Runtime​

When using Relay Resolvers, we recommend configuring a fieldLogger in your Relay Enviornment in order to track errors which have been thrown within Relay resolver functions.

import { Environment, RecordSource, RelayFeatureFlags } from "relay-runtime";
import RelayModernStore from "relay-runtime/lib/store/RelayModernStore";

// It is recommended to log errors thrown by Resolvers
function fieldLogger(event) {
if(event.kind === "relay_resolver.error") {
// Log this somewhere!
console.warn(`Resolver error encountered in ${event.owner}.${event.fieldPath}`)
console.warn(event.error)
}
}

const environment = new Environment({
network: Network.create(/* your fetch function here */),
store: new RelayModernStore(new RecordSource()),
relayFieldLogger: fieldLogger
});

// ... create your Relay context with your environment