apollo icon indicating copy to clipboard operation
apollo copied to clipboard

can't use useQuery

Open itaysmalia opened this issue 4 years ago • 3 comments

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 avatar Jan 08 '21 15:01 itaysmalia

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

itaysmalia avatar Jan 08 '21 18:01 itaysmalia

@itaysmalia were you able to make this work?

ghost avatar Apr 05 '21 11:04 ghost

@itaysmalia were you able to make this work?

Not yet.

itaysmalia avatar Apr 05 '21 20:04 itaysmalia