Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typescript-vue-apollo.mdx #9776

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 9 additions & 13 deletions website/src/pages/plugins/typescript/typescript-vue-apollo.mdx
Expand Up @@ -77,7 +77,7 @@ query allAccounts {
}
```

We can use the generated code with `useResult` like this:
We can use the generated code with a watcher like this:

```vue
<template>
Expand All @@ -91,20 +91,16 @@ We can use the generated code with `useResult` like this:
</div>
</div>
</template>

<script lang="ts">
<script setup lang="ts">
import { defineComponent } from '@vue/composition-api'
hinogi marked this conversation as resolved.
Show resolved Hide resolved
import { useResult } from '@vue/apollo-composable'
import { useAllAccountsQuery } from '../generated/graphqlOperations'

export default defineComponent({
setup() {
const { result, loading, error } = useAllAccountsQuery()
// Only select the property 'accounts' for use in the template
const allAccounts = useResult(result, null, data => data.accounts)
return { allAccounts, loading, error }
}
})
import { ref, watch } from 'vue'

const { result, loading, error } = useAllAccountsQuery()
const allAccounts = ref();
// Only select the property 'accounts' for use in the template
watch(result, data => allAccounts.value = data.accounts)
</script>
```

Expand Down