What is Relay?
mainRelay is a JavaScript framework designed for building data-driven React applications. It focuses on three core principles:
- Declarative Data Fetching: Instead of using imperative APIs to communicate with a data store, you declare your data requirements using GraphQL. Relay manages the orchestration of how and when that data is fetched.
- Colocation: GraphQL queries are placed directly next to the React components that require them. This allows Relay to aggregate these fragmented queries into efficient, single network requests.
- Mutations: Relay handles data mutations on both the client and server using GraphQL mutations, providing built-in support for automatic data consistency, optimistic updates, and error handling.