본문으로 건너뛰기

GraphQL Atom Effects

The underlying GraphQL synchronization support is provided via atom effects. While GraphQL selectors are provided as a convenience to make them easier to use, you could also apply these effects directly to atoms. To use these, you'll need to either reference or register your Relay environment.

There are three atom effects that correspond with the three types of GraphQL operations:

graphQLQueryEffect()

This effect initializes an atom with the results of a GraphQL query. Data may potentially load incrementally with @defer or live queries. This effect will also automatically update the atom if you issue a local Relay useMutation(), commitMutation(), or commitLocalUpdate() call that updates the same part of the graph. GraphQL fragments are also supported.

graphQLSubscriptionEffect()

If you also want to subscribe to mutations initiated remotely from the server, in addition to local changes, then you can implement a GraphQL subscription on the server and use this instead of a query.

graphQLMutationEffect()

This effect causes any local mutations to the atom to be committed as a GraphQL mutation operation.