Fetching data
#
PrerequisitesMake sure you've completed Getting Started first.
../gqless
refers to the generated directory.
GQless is a framework-agnostic GraphQL client, and can be used anywhere (we might add more bindings for other Frontend frameworks in the future).
#
Fetching dataresolved
#
Accepts a callback, which will be recursively executed, until the data has been fetched (or an error occurs). The final result of the callback is returned as a promise.
If your request has any error, either from syntax or from the GraphQL API,
it will always throw an instance of GQlessError
(which is itself, an instance of Error
)
You can specify options in the second argument, like forcing a refetch or isolating from existing cache, see ResolveOptions.
inlineResolved
#
inlineResolved
is the exact same as resolved, but it returns the data straight away if it can.
#
Refetching datarefetch
#
A special function that accepts object proxies, or functions.
When dealing with object proxies, it recovers all the history of the specific object down the tree of selections, and refetchs them, returning the same object back after all the resolutions are done.
On the other hand, when used with a function, it calls the function (using the core scheduler) ignoring possible nulls in the middle in the first pass, and returns whatever the function gave back as a promise.
#
Using the Scheduler directlyGQless exposes the Scheduler API, which is used by the helper functions above.
#
Error handlingThe scheduler resolves to a promise of a GQlessError
: