Class: FetchQL

FetchQL(options)

GraphQL client with fetch api.

Constructor

new FetchQL(options)

Create a FetchQL instance.
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
url String the server address of GraphQL
interceptors Object | Array.<Object> <optional>
headers Object <optional>
request headers
onStart FetchQL~requestQueueChanged <optional>
callback function of a new request queue
onEnd FetchQL~requestQueueChanged <optional>
callback function of request queue finished
omitEmptyVariables Boolean <optional>
remove null props(null or '') from the variables
requestOptions Object <optional>
addition options to fetch request(refer to fetch api)
Source:

Extends

Methods

addInterceptors(interceptors)

add new interceptors
Parameters:
Name Type Description
interceptors Object | Array.<Object>
Overrides:
Source:

clearInterceptors()

remove all interceptors
Overrides:
Source:

getEnumTypes(EnumNameList) → {Promise}

get information of enum type
Parameters:
Name Type Description
EnumNameList Array.<String> array of enums' name
Source:
Returns:
Type
Promise

getUrl() → {String}

get current server address
Source:
Returns:
Type
String

onEnd()

calling on a request ending if current queue finished, calling the 'onEnd' method
Source:

onStart()

calling on a request starting if the request belong to a new queue, call the 'onStart' method
Source:

query(options) → {Promise}

operate a query
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
operationName String
query String
variables Object <optional>
opts Object <optional>
addition options(will not be passed to server)
Properties
Name Type Attributes Description
omitEmptyVariables Boolean <optional>
remove null props(null or '') from the variables
requestOptions Object <optional>
addition options to fetch request(refer to fetch api)
Source:
Returns:
Type
Promise

removeInterceptors(indexes)

remove interceptors by indexes
Parameters:
Name Type Description
indexes Array.<number>
Overrides:
Source:

setUrl(url)

setting a new server address
Parameters:
Name Type Description
url String
Source:

Type Definitions

requestQueueChanged(queueLength)

Callback of requests queue changes.(e.g. new queue or queue finished)
Parameters:
Name Type Description
queueLength number length of current request queue
Source: