-export const getPost = (id: string) =>
- store<Post>({ key: 'post', query: GET_POST, variables: { id } });
+const client = createClient(supabase.url, supabase.key);
+
+export const post = (id: string, withTopic = false) => single<Post>(client
+ .from('posts')
+ .select(withTopic ? `*,
+ topic:topic_id (
+ *
+ )
+ `: '*' )
+ .eq('id', id),
+ null);
+export const postsForTopic = (id: string) => collection<Post>(client
+ .from('posts')
+ .select('*')
+ .eq('topic_id', id)
+ .order('created_at', { ascending: true }),
+ []);