vuejs / apollo

🚀 Apollo/GraphQL integration for VueJS
http://apollo.vuejs.org
MIT License
6k stars 519 forks source link

can't use useQuery #1126

Open itaysmalia opened 3 years ago

itaysmalia commented 3 years ago

just trying a super simple useQuery and it throws an error Uncaught (in promise) ReferenceError: getCurrentInstance is not defined

code:

<template>
  <div class="h-full flex items-center justify-center">
    <h1 class="text-8xl">username here</h1>
  </div>
</template>

<script lang="ts">
import { watch } from "vue";
import { useQuery } from "@vue/apollo-composable";
import gql from "graphql-tag";
export default {
  props: ["id"],
  setup({ id }) {
    id = parseInt(id);
    const { result } = useQuery(
      gql`
        query getUsers {
          user {
            id
            username
          }
        }
      `
    );
    watch(result, value => {
      console.log(value);
    });
    return { id };
  }
};
</script>

<style></style>

To Reproduce Steps to reproduce the behavior:

  1. Use useQuery
  2. See the error

Expected behavior get the result of the query

Versions vue: "vue": "^3.0.0" vue-apollo: "@vue/apollo-composable": "^4.0.0-alpha.12", apollo-client: "@apollo/client": "^3.3.6" "snowpack": "^2.18.4", "@snowpack/plugin-vue": "^2.2.6",

itaysmalia commented 3 years ago

using snowpack btw: "snowpack": "^2.18.4", "@snowpack/plugin-vue": "^2.2.6",

ghost commented 3 years ago

@itaysmalia were you able to make this work?

itaysmalia commented 3 years ago

@itaysmalia were you able to make this work?

Not yet.