MCPcopy Create free account
hub / github.com/TanStack/query / usePosts

Function usePosts

examples/react/basic-graphql-request/src/index.tsx:47–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45}
46
47function usePosts() {
48 return useQuery({
49 queryKey: ['posts'],
50 queryFn: async () => {
51 const {
52 posts: { data },
53 } = await request<{ posts: { data: Array<Post> } }>(
54 endpoint,
55 gql`
56 query {
57 posts {
58 data {
59 id
60 title
61 }
62 }
63 }
64 `,
65 )
66 return data
67 },
68 })
69}
70
71function Posts({
72 setPostId,

Callers 1

PostsFunction · 0.70

Calls 1

useQueryFunction · 0.90

Tested by

no test coverage detected