# UseDQLQuery autoFetch property

**URL:** <https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038>\
**Category:** Developer Q&A Forum\
**Created:** [November 24, 2024, 11:59pm UTC](https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038 "2024-11-24T23:59:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jwrogers](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jwrogers](https://community.dynatrace.com/u/Jwrogers)\
**Post date:** [November 24, 2024, 11:59pm UTC](https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038/1 "2024-11-24T23:59:08Z")

</div>

UseDQLQuery autoFetch set to false still runs query on react component load. Why?

---

<div class="post-metadata">

**Author:** ![haris](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/haris/32/38293_2.png) [@haris](https://community.dynatrace.com/u/haris)\
**Post date:** [November 25, 2024, 11:15am UTC](https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038/2 "2024-11-25T11:15:34Z")

</div>

Hi Jwrogers,

can you please give us the code snippet to fully understand the usage?

---

<div class="post-metadata">

**Author:** ![Jwrogers](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jwrogers](https://community.dynatrace.com/u/Jwrogers)\
**Post date:** [November 25, 2024, 1:25pm UTC](https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038/3 "2024-11-25T13:25:21Z")

</div>

I build the fetch bizEvents DQL in the method getPipelineSummary(), but I don’t want it to trigger until I call refetch().

```javascript
useEffect(() => {
    setDetails(details);
    refetch();
  }, []);

const { data, isLoading, refetch } = useDqlQuery(
    {
      body: { query: dbQueries.getPipelineSummary() },
    },
    { autoFetch: false, autoFetchOnUpdate: false },
  );

```

---

<div class="post-metadata">

**Author:** ![imsingh](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/imsingh/32/7858_2.png) [@imsingh](https://community.dynatrace.com/u/imsingh)\
**Post date:** [November 25, 2024, 4:08pm UTC](https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038/4 "2024-11-25T16:08:01Z")

</div>

Hi there

When the component loads, it calls the `useEffect` hook. In this hook, you’re calling refetch. If you dont’ want the query to run when component loads, just remove that execution of refetch as following:

```javascript
useEffect(() => {
    setDetails(details);
  }, []);

const { data, isLoading, refetch } = useDqlQuery(
    {
      body: { query: dbQueries.getPipelineSummary() },
    },
    { autoFetch: false, autoFetchOnUpdate: false },
  );

```

---

<div class="post-metadata">

**Author:** ![Jwrogers](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jwrogers](https://community.dynatrace.com/u/Jwrogers)\
**Post date:** [January 13, 2025, 4:20pm UTC](https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038/5 "2025-01-13T16:20:52Z")

</div>

I removed refetch from being called anywhere in my component, but it’s still being called when the component loads:

 ![Jwrogers_0-1736785232425.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/db952946ac8dc2ece1820a6bf91b80a51f56e2dc.png)

---

<div class="post-metadata">

**Author:** ![imsingh](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/imsingh/32/7858_2.png) [@imsingh](https://community.dynatrace.com/u/imsingh)\
**Post date:** [January 13, 2025, 4:44pm UTC](https://community.dynatrace.com/t/usedqlquery-autofetch-property/49038/6 "2025-01-13T16:44:32Z")

</div>

Hi there

Do you have full code snippet that you can share or codesandbox?&nbsp;  
That’ll help me solve your issue much better.

Thanks
