MCPcopy Index your code
hub / github.com/TanStack/query / createPost

Function createPost

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

Source from the content-addressed store, hash-verified

117}
118
119function createPost(postId: Accessor<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(props: { postId: number; setPostId: Setter<number> }) {
143 const state = createPost(() => props.postId)

Callers 1

PostFunction · 0.70

Calls 1

useQueryFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…