- Fragment is the building block of the relay
- Fragment is a selection of fields on a GraphQL Type
- Fragment allow you to colocate data
- Relay composes fragments from multiple components into optimized and efficient batches to reduce round-trips to the server
- Its hard to over-fetch and under-fetch
- Components can only access data they've asked for - data mask - each one must declare its own data requirements without relying on others
- Components only re-render when the exact data they're using is updated, preventing unnecessary re-renders
- In short, colocating data make your components modular, easier to refactor, more performant and less error-prone
- Relay requires globally unique fragments names. The convention is <module_name>_<property_name>
- The fragment reference is the object that contains the fragment in the root query, passed into the component as a prop from the parent component. Is like a pointer to a specific instance of a type that we want read data from
Created
September 11, 2020 13:52
-
-
Save AugustoCalaca/7ee5b9c4b55556ec58e26242c3a5dacb to your computer and use it in GitHub Desktop.
Resume about relay fragments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment