probo / rules
getprobo/probo/.cursor/rules/relay-fragments-not-data-props.mdc
Enforce Relay fragments instead of passing fetched data as props
Cursor rule1.4k starsChanged 3 months ago
What's in it
- Never pass fetched data as props — use Relay fragments
---
description: Enforce Relay fragments instead of passing fetched data as props
globs: "**/*.tsx"
alwaysApply: false
---
# Never pass fetched data as props — use Relay fragments
When a child component needs data from a GraphQL node, it MUST define its own
colocated fragment and receive a **fragment key** (`SomeFragment$key`), never
a plain object or individual fields extracted from the parent's query/fragment.
This applies even when the child only uses the data to seed local state (e.g.
an edit form that copies fields into `useState`).
```tsx
// BAD — parent extracts fields and passes a plain object
<EditCookieRow
cookie={{ name: cookie.name, duration: cookie.duration }}
onSave={handleSave}
/>
// GOOD — child owns its fragment, parent spreads it and passes the key
// In EditCookieRow.tsx:
export const editCookieRowFragment = graphql`
fragment EditCookieRowFragment on Cookie { name duration description }
`;
interface EditCookieRowProps {
cookieKey: EditCookieRowFragment$key;
onSave: (cookie: CookieEntry) => void;
}
// In parent fragment:
// ...EditCookieRowFragment (spread on the Cookie node)
// In parent JSX:
<EditCookieRow cookieKey={cookie} onSave={handleSave} />
```
Callback props (`onSave`, `onCancel`) and configuration props (`isUpdating`,
`variant`) are fine — only **domain data** must come from fragments.
For connection items (table rows, list entries rendered in `.map()`), see the
companion rule `relay-connection-item-components.mdc`.
More agent context in getprobo/probo
29 other files this repository gives its agents.
AGENTS.md
CLAUDE.md
Cursor rule
- .cursor/rules/code-comments.mdc
- .cursor/rules/config-propagation.mdc
- .cursor/rules/coredata-migrations.mdc
- .cursor/rules/detail-page-back-link.mdc
- .cursor/rules/git-commit-signing.mdc
- .cursor/rules/git-commit-style.mdc
- .cursor/rules/go-authorize-scope.mdc
- .cursor/rules/go-coredata-load-naming.mdc
- .cursor/rules/go-declarations.mdc
- .cursor/rules/go-delete-no-rows-check.mdc
- .cursor/rules/go-error-handling.mdc
- .cursor/rules/go-imports.mdc
- .cursor/rules/go-logging.mdc
- .cursor/rules/go-multiline-params.mdc
- .cursor/rules/go-naming-conventions.mdc
- .cursor/rules/go-pg-constraint-check.mdc
- .cursor/rules/go-upsert-returning-id.mdc
- .cursor/rules/go-url-construction.mdc
- .cursor/rules/list-filtering.mdc
- .cursor/rules/no-outlet-context-data.mdc
- .cursor/rules/prompt-style.mdc
- .cursor/rules/react-named-exports-lazy-entry.mdc
- .cursor/rules/relay-connection-item-components.mdc
- .cursor/rules/relay-required-directive.mdc
- .cursor/rules/skeleton-width-sync.mdc
- .cursor/rules/template-files.mdc
- .cursor/rules/v2-color-scale.mdc
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

