1

Let's say you have this use case:

A simple form with one input and a submit button.

When the input value is valid (>3 chars) you want to query the server to see if the value is already in use.

The button should be disabled when A. input value is <4 chars B. input value is already in use (response from server)

I tried to do it with usePreloadedQuery

The probleme is that the button that should always be visible will call usePreloadedQuery before a query is ever fired and therefore will throw because the queryRef is null.

I tried to do it with useLazyLoadQuery

I tried to use useLazyLoadQuery and set { fetchPolicy: value.length < 4 ? "store-only" : "network-or-store" } but then it forces me to have a Suspense fallback higher which will make my component disappear on every key push over 3 chars.

What would be the best way to achieve this with Relay?

Malo Guertin
  • 307
  • 2
  • 16

0 Answers0