我正在使用Relay(GraphQL客户端)并重构需要isFetching, hasInitialResults
布尔标志值的旧代码。我应该自己设置它们(例如hasInitialResults = query.error != null
)还是在GraphQL客户端中可用?
有一个类似的question,但对我而言,中继可能会返回
error = null, props.foo.data = null, props.foo.error = { code: 401, message: ... }
即,如果我使用接受的答案,则可能是错误的:
<Relay.Renderer
Container={ProfilePicture}
queryConfig={profileRoute}
environment={Relay.Store}
render={({done, error, props, retry, stale}) => {
if (error) {
return <ErrorComponent />;
} else if (props) {
// <--- still have 401 here
return <ProfilePicture {...props} />;
} else {
return <LoadingComponent />;
}
}}
/>