mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-27 10:00:33 +00:00
35 lines
610 B
TypeScript
35 lines
610 B
TypeScript
import { ApolloClient } from 'apollo-client';
|
|
import query from 'mobx-apollo';
|
|
|
|
const PostsQuery = `
|
|
{
|
|
posts {
|
|
id
|
|
title
|
|
}
|
|
}
|
|
` as any;
|
|
|
|
interface Post {
|
|
id: string;
|
|
title: string;
|
|
}
|
|
|
|
class PostStore {
|
|
private get postsQuery() {
|
|
return query<{ posts: Post[] }>({
|
|
client: new ApolloClient({
|
|
link: {} as any,
|
|
cache: {} as any
|
|
}),
|
|
query: PostsQuery
|
|
});
|
|
}
|
|
|
|
get posts() {
|
|
return this.postsQuery.data && this.postsQuery.data.posts;
|
|
}
|
|
}
|
|
|
|
new PostStore();
|