useLazyQuery
扩展 useQuery
附加返回值
load(document?, variables?, options?)
: 用于启动查询的函数。如果这是第一次调用查询,则返回Promise<Result>
,否则返回false
。示例
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 } }