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

Function usePost

examples/react/basic-graphql-request/src/index.tsx:119–140  ·  view source on GitHub ↗
(postId: number)

Source from the content-addressed store, hash-verified

117}
118
119function usePost(postId: number) {
120 return useQuery({
121 queryKey: ['post', postId],
122 queryFn: async () => {
123 const { post } = await request<{ post: Post }>(
124 endpoint,
125 gql`
126 query {
127 post(id: ${postId}) {
128 id
129 title
130 body
131 }
132 }
133 `,
134 )
135
136 return post
137 },
138 enabled: !!postId,
139 })
140}
141
142function Post({
143 postId,

Callers 1

PostFunction · 0.70

Calls 1

useQueryFunction · 0.90

Tested by

no test coverage detected