gqty-dev/gqty

Don't warn ✘ [ERROR] [gqty] Warning! No data requested. if onEmptyResolve is provided for a query #245

Closed this issue · 3 comments

I think we could avoid having the warning if an onEmptyResolve is explicitly provided in development mode. What do you think?

vicary commented

The current active development is in the v3 branch, new changes are preferably happening there.

If you don't mind trying out v3 canary, this warning is shown only when NODE_ENV !== 'production'.

We kept all the v2 methods, e.g. resolved and inlineResolved, in v3 for progressive migration, and it is possible to supress the warning when onEmptyResolve is specified in production. But then I am really curious about your use case if you want this.

Hey, thanks for getting back. My suggestion would be to generally suppress it (dev or prod) if an onEmptyResolve is provided, because this means that the dev is explicitly acknowledging their query might be returning empty, thus probably doesn't want to clutter the logs with that warning.

Or maybe allow a setting to disable this warning?

Thanks for considering!

vicary commented

In 3.0.0-canary-20231124072611.3a09ecd6, inlineResolved and resolved will now skip the warning when onEmptyResolve is specified.

To make sure I have covered your use case, consider these differences in v3.

  1. React: useQuery in v3 automatically skips the fetch when its not read, thus never triggers this warning.
  2. Core: resolve in v3, in contrast with resolved in v2, does not accept onEmptyResolve.
    It will warn when NODE_ENV !== 'production' and we have no plans to change this.
    resolve(({ query }) => {
      // warns if query was never read here
    });