graphQLMutationEffect()
用于使 Atom 的本地更新引发对服务器提交 GraphQL 变异 的基础 Atom effect。
请注意,如果 Atom 有多个更新其值的 Atom effects,则其他 effects 可能会导致 graphQLMutationEffect() 启动服务器变异。因此,如果尝试与 graphQLQueryEffect() 结合使用,则应谨慎。如果需要,使用 graphQLSelector() 可能更容易。
function graphQLMutationEffect<
TVariables: Variables,
T,
TResponse: $ReadOnly<{[string]: mixed}> = {},
TRawResponse = void,
>({
environment: IEnvironment | EnvironmentKey,
mutation: Mutation<TVariables, TResponse, TRawResponse>,
variables: T => TVariables | null,
updater_UNSTABLE?: SelectorStoreUpdater<TResponse>,
optimisticUpdater_UNSTABLE?: SelectorStoreUpdater<TResponse>,
optimisticResponse_UNSTABLE?: T => TResponse,
uploadables_UNSTABLE?: UploadableMap,
}): AtomEffect<T>
environment: Relay 环境或一个EnvironmentKey,用于与<RecoilRelayEnvironemnt>提供的环境匹配。mutation: GraphQL 变异。variables: 提供新的 Atom 值的回调函数,该回调函数返回作为 GraphQL 变异的输入提供的变量对象。如果它返回null,则变异将被跳过。
可选选项
updater_UNSTABLE: 传递给commitMutation()的可选updater()函数。optimisticUpdater_UNSTABLE: 传递给commitMutation()的可选optimisticUpdater()函数。optimisticResponse_UNSTABLE: 传递给commitMutation()的可选乐观响应。uploadables_UNSTABLE: 传递给commitMutation()的可选uploadables。