Created
August 7, 2019 10:23
-
-
Save Jursdotme/66e5075d9eeb15bbdf4837759ef1734c to your computer and use it in GitHub Desktop.
Vue component with apollo problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<nuxt-link | |
v-for="post in posts" | |
:key="post.id" | |
:to="`/post/${post.id}`" | |
class="border-b pb-5 mt-5" | |
> | |
<h2 class="text-4xl">{{ post.title }}</h2> | |
<VueMarkdown id="content">{{ post.content }}</VueMarkdown> | |
</nuxt-link> | |
</div> | |
</template> | |
<script> | |
import VueMarkdown from 'vue-markdown' | |
import gql from 'graphql-tag' | |
const posts = gql` | |
query posts($first: Int!, $skip: Int!) { | |
posts(orderBy: createdAt_ASC, first: $first, skip: $skip) { | |
id | |
slug | |
title | |
content | |
} | |
} | |
` | |
export default { | |
name: 'BlogPostsCards', | |
components: { | |
VueMarkdown | |
}, | |
props: { | |
initialPosts: { | |
type: Number, | |
default: 3 | |
} | |
}, | |
data: () => ({ | |
loading: 0 | |
}), | |
apollo: { | |
posts: { | |
query: posts, | |
variables: { | |
first: 3, | |
skip: 0, | |
orderBy: 'updatedAt_ASC' | |
} | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment