storybook/docs/snippets/vue/document-screen-with-graphql.3.js.mdx
2022-11-17 16:33:22 +01:00

59 lines
1.2 KiB
Plaintext

```html
<!-- YourPage.vue -->
<template>
<div v-if="loading">Loading...</div>
<div v-else-if="error">There was an error fetching the data!</div>
<div v-if="!loading && data && result.subdocuments.length">
<PageLayout :user="data.user">
<DocumentHeader :document="result.document" />
<DocumentList :documents="result.subdocuments" />
</PageLayout>
</div>
</template>
<script>
import PageLayout from './PageLayout';
import DocumentHeader from './DocumentHeader';
import DocumentList from './DocumentList';
import gql from 'graphql-tag';
import { useQuery } from '@vue/apollo-composable';
export default {
name: 'DocumentScreen',
setup() {
const { result, loading, error } = useQuery(gql`
query AllInfoQuery {
user {
userID
name
}
document {
id
userID
title
brief
status
}
subdocuments {
id
userID
title
content
status
}
}
`);
return {
result,
loading,
error,
};
},
};
</script>
```