question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[AFTER PATCH] Did you forget to call `useClient`?

See original GitHub issue

Versions with Issue : Rc0 + Rc1

image

Issue happens when getReport() is called on change of a date. When getReport() is called during page load /setup it works fine.

Logic of program is when date input is changed, send useQuery to fetch data using the selected date.

App.VUE

<script lang="ts">
import { SubscriptionClient } from "subscriptions-transport-ws";
import { defineComponent, computed } from "vue";
import DesktopMenu from "./components/DesktopMenu.vue";
import { router } from "./main";
import { useClient } from "villus";

import { ActionTypes, MutationTypes, useStore } from "./store";

export default defineComponent({
  name: "Navigation",
  components: {
    DesktopMenu,
  },
  setup() {
    const store = useStore();

    useClient({
      url: "/graphql",
    });

  },
});
</script>

Home.VUE

<template>
  <div>
    Home
    <input v-model="datePage" type="date" />
    <p v-if="returnData">
      {{ returnData }}
    </p>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, computed, watchEffect } from "vue";
import { useQuery } from "villus";

import { CostDocument } from "../generated/graphql-operations";

export default defineComponent({
  name: "HelloWorld",
  setup() {
    const returnData = ref();
    const datePage = ref("2020-10-18");
    const formattedDate = computed(() =>
      datePage.value.toString().split("-").join(""),
    );

    const data = ref(null);
    watchEffect(async (datePage) => {
      async function getReport() {
        try {
          console.log("date value changed:", formattedDate);

          const { data, error } = await useQuery({
            query: CostDocument,
            variables: { date: formattedDate.value },
          });

          console.log("Query:", data, error);
          returnData.value = data;
        } catch (error) {
          console.log("error", error);
        }
      }
      data.value = await getReport();
    });

    return { returnData, datePage };
  },
});
</script>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kingkong404commented, Oct 26, 2020

Fixed with reactive. No more help needed.

Thanks again or all your hard work on Villus!

1reaction
logaretmcommented, Oct 26, 2020

Couldn’t you disable fetchOnMount and just execute whenever you need to?

const { execute } = await useQuery({
  query: CostDocument,
  variables: { date: formattedDate.value },
  fetchOnMount: false, 👈
});

async function getReport() {
  try {
    console.log('date value changed:', formattedDate);
    const { data, error } = await execute(); // 👈
    console.log('Query:', data, error);
    returnData.value = data;
  } catch (error) {
    console.log('error', error);
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot detect villus Client, did you forget to call useClient ? #72
When i use UseQuery in a child component, i don't have any error. We cannot use useClient and useQuery in the same level...
Read more >
Designing GraphQL Mutations
If you start with a general “catch-all” mutation, adding extra inputs is much more difficult. Don't be afraid of super specific mutations that ......
Read more >
What could happen if I don't close response.Body?
The connection won't be re-used, and can remain open in which case the file descriptor won't be freed. Also is it safe to...
Read more >
560361 – Dhclient doesn't use client-identifier - Red Hat Bugzilla
No, I don't have any hardware infiniband entries. Last I knew, they weren't supported on rhel7 dhcpd and just fail. No, what you...
Read more >
What's New in Next.js 13 - AppSignal Blog
You can use Client Components by specifying a "use client" directive at the ... In other cases, when you don't need things from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found