relay-pagination
Use when relay pagination with cursor-based pagination, infinite scroll, load more patterns, and connection protocols.
What this skill does
# Relay Pagination
Master Relay's cursor-based pagination for efficiently loading and displaying
large datasets with infinite scroll and load more patterns.
## Overview
Relay implements the GraphQL Cursor Connections Specification for efficient
pagination. It provides hooks like usePaginationFragment for declarative
pagination with automatic cache updates and connection management.
## Installation and Setup
### Pagination Query Structure
```graphql
# schema.graphql
type Query {
posts(
first: Int
after: String
last: Int
before: String
): PostConnection!
}
type PostConnection {
edges: [PostEdge!]!
pageInfo: PageInfo!
totalCount: Int
}
type PostEdge {
cursor: String!
node: Post!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
type Post {
id: ID!
title: String!
body: String!
}
```
## Core Patterns
### 1. Basic Pagination
```javascript
// PostsList.jsx
import { graphql, usePaginationFragment } from 'react-relay';
const PostsListFragment = graphql`
fragment PostsList_query on Query
@refetchable(queryName: "PostsListPaginationQuery")
@argumentDefinitions(
first: { type: "Int", defaultValue: 10 }
after: { type: "String" }
) {
posts(first: $first, after: $after)
@connection(key: "PostsList_posts") {
edges {
node {
id
...PostCard_post
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
`;
function PostsList({ query }) {
const {
data,
loadNext,
loadPrevious,
hasNext,
hasPrevious,
isLoadingNext,
isLoadingPrevious,
refetch
} = usePaginationFragment(PostsListFragment, query);
return (
<div>
<button
onClick={() => refetch({ first: 10 })}
disabled={isLoadingNext}
>
Refresh
</button>
{data.posts.edges.map(({ node }) => (
<PostCard key={node.id} post={node} />
))}
{hasNext && (
<button
onClick={() => loadNext(10)}
disabled={isLoadingNext}
>
{isLoadingNext ? 'Loading...' : 'Load More'}
</button>
)}
</div>
);
}
export default PostsList;
```
### 2. Infinite Scroll
```javascript
// InfiniteScrollPosts.jsx
import { useEffect, useRef } from 'react';
import { graphql, usePaginationFragment } from 'react-relay';
const InfiniteScrollFragment = graphql`
fragment InfiniteScrollPosts_query on Query
@refetchable(queryName: "InfiniteScrollPostsQuery")
@argumentDefinitions(
first: { type: "Int", defaultValue: 20 }
after: { type: "String" }
) {
posts(first: $first, after: $after)
@connection(key: "InfiniteScroll_posts") {
edges {
node {
id
...PostCard_post
}
}
}
}
`;
function InfiniteScrollPosts({ query }) {
const { data, loadNext, hasNext, isLoadingNext } = usePaginationFragment(
InfiniteScrollFragment,
query
);
const observerRef = useRef();
const loadMoreRef = useRef();
useEffect(() => {
const observer = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting && hasNext && !isLoadingNext) {
loadNext(20);
}
},
{ threshold: 0.5 }
);
const currentRef = loadMoreRef.current;
if (currentRef) {
observer.observe(currentRef);
}
observerRef.current = observer;
return () => {
if (currentRef) {
observer.unobserve(currentRef);
}
};
}, [hasNext, isLoadingNext, loadNext]);
return (
<div>
{data.posts.edges.map(({ node }) => (
<PostCard key={node.id} post={node} />
))}
{hasNext && (
<div ref={loadMoreRef} className="load-more-trigger">
{isLoadingNext && <Spinner />}
</div>
)}
{!hasNext && <div>No more posts</div>}
</div>
);
}
```
### 3. Bidirectional Pagination
```javascript
// BidirectionalPosts.jsx
const BidirectionalFragment = graphql`
fragment BidirectionalPosts_query on Query
@refetchable(queryName: "BidirectionalPostsQuery")
@argumentDefinitions(
first: { type: "Int" }
after: { type: "String" }
last: { type: "Int" }
before: { type: "String" }
) {
posts(first: $first, after: $after, last: $last, before: $before)
@connection(key: "Bidirectional_posts") {
edges {
node {
id
...PostCard_post
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
`;
function BidirectionalPosts({ query }) {
const {
data,
loadNext,
loadPrevious,
hasNext,
hasPrevious,
isLoadingNext,
isLoadingPrevious
} = usePaginationFragment(BidirectionalFragment, query);
return (
<div>
{hasPrevious && (
<button
onClick={() => loadPrevious(10)}
disabled={isLoadingPrevious}
>
{isLoadingPrevious ? 'Loading...' : 'Load Previous'}
</button>
)}
{data.posts.edges.map(({ node }) => (
<PostCard key={node.id} post={node} />
))}
{hasNext && (
<button
onClick={() => loadNext(10)}
disabled={isLoadingNext}
>
{isLoadingNext ? 'Loading...' : 'Load Next'}
</button>
)}
</div>
);
}
```
### 4. Filtered Pagination
```javascript
// FilteredPosts.jsx
const FilteredPostsFragment = graphql`
fragment FilteredPosts_query on Query
@refetchable(queryName: "FilteredPostsQuery")
@argumentDefinitions(
first: { type: "Int", defaultValue: 10 }
after: { type: "String" }
status: { type: "PostStatus" }
authorId: { type: "ID" }
) {
posts(
first: $first
after: $after
status: $status
authorId: $authorId
)
@connection(key: "FilteredPosts_posts") {
edges {
node {
id
...PostCard_post
}
}
}
}
`;
function FilteredPosts({ query }) {
const [status, setStatus] = useState('PUBLISHED');
const [authorId, setAuthorId] = useState(null);
const { data, loadNext, hasNext, refetch } = usePaginationFragment(
FilteredPostsFragment,
query
);
const handleFilterChange = (newStatus, newAuthorId) => {
setStatus(newStatus);
setAuthorId(newAuthorId);
refetch({
first: 10,
after: null,
status: newStatus,
authorId: newAuthorId
});
};
return (
<div>
<FilterControls
status={status}
authorId={authorId}
onChange={handleFilterChange}
/>
{data.posts.edges.map(({ node }) => (
<PostCard key={node.id} post={node} />
))}
{hasNext && (
<button onClick={() => loadNext(10)}>Load More</button>
)}
</div>
);
}
```
### 5. Pagination with Search
```javascript
// SearchablePosts.jsx
const SearchablePostsFragment = graphql`
fragment SearchablePosts_query on Query
@refetchable(queryName: "SearchablePostsQuery")
@argumentDefinitions(
first: { type: "Int", defaultValue: 10 }
after: { type: "String" }
searchTerm: { type: "String" }
) {
posts(first: $first, after: $after, searchTerm: $searchTerm)
@connection(key: "SearchablePosts_posts") {
edges {
node {
id
...PostCard_post
}
}
totalCount
}
}
`;
function SearchablePosts({ query }) {
const [searchTerm, setSearchTerm] = useState('');
const { data, loadNext, hasNext, refetch, isLoadingNext } =
usePaginationFragment(SearchablePostsFragment, query);
const handleSearch = (term) => {
setSearchTerm(term);
refetch({
first: 10,
after: null,
searchTerm: term
});
};
return (
<div>
<SearchInput
value={searchTerm}
onChange={handleSearch}
placeholder="Search posts..."
/>
<div>
Showing {data.posts.edges.lengtRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.