How to use the apollo.query function in apollo

To help you get started, we’ve selected a few apollo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Vheissu / aurelia-graphql-apollo / src / routes / post.ts View on Github external
async canActivate({ postSlug }) {
        try {
            const { data: { post } } = await query(`query {
                post(slug: "${postSlug}") {
                    id,
                    title,
                    body
                }
            }`) as ApolloQueryResult;

            this.post = post;
        } catch (e) {
            throw new Error('Could not load post');
        }
    }
}
github Vheissu / aurelia-graphql-apollo / src / routes / home.ts View on Github external
async activate() {
        try {
            const { data: { posts } } = await query(`query {
                posts() {
                    id,
                    title,
                    body
                }
            }`) as ApolloQueryResult;

            this.posts = posts;
        } catch (e) {
            throw new Error('Could not load posts');
        }
    }
}