useLazyQuery
Extends useQuery
Additional Return
load(document?, variables?, options?)
: function to start querying. ReturnsPromise<Result>
if it is the first time the query is called,false
otherwise.Example:
jsconst { load, refetch } = useLazyQuery(query, variables, options) function fetchOrRefetch () { load() || refetch() } function waitForLoad () { try { const result = await load() // do something with result } catch (error) { // handle error } }