class Connector
Base class for objects defining how to mutate and retrieve data from remote resources.
Typically, these will be API clients for remote web services used to resolve GraphQL requests.
Connector instances have access to the request context, so they are able to retrive authentication credentials and inject useful helper objects such as HttpClient.
A common use case for a connector is to get a resource by id.
Where a resource is identified by a string id, subclassing a Connector using
withIdentify
and defining how to fetch a batch of resources by id will expose additional
methods on your Connector subclass such as fetchOne
, which will batch and de-duplicate
get requests to remote services made over a single incoming request.
class ResourceBatchFetcher<IdType, Value>
Batch retriever class describing how to fetch a batch of resources by ID.
Subclasses of ResourceBatchFetcher are a special case of connectors. Although written like other connectors, they consist of a single method and are not called directly from your ResolverMap.
Instead, when you subclass ResourceWithIdConnector, your ResourceBatchFetcher subclass is passed as a parameter, defining how the ResourceWithIdConnector should get a batch of resources by ID.
class ResourceWithIdConnector<IdType, Value>
Base class for objects defining how to mutate and retrieve data from remote resources where the resource can be uniquely identified and retrieved using a single ID.
class SchemaType
Base class for implementing resolver maps.
ResolverMaps are collections of resolver functions, each one being responsible for defining how to resolve properties declared in an API’s schema.
When a resolver function is written for a scalar property (such as a string or number), it should return either the scalar value or (more typically) a Promise for the scalar value.
When a resolver function is written for a relation to another object, it should not fetch the object, but instead return a string ID for that object. This is then provided to that Object's ResolverMap as its id property, which can then be used by the functions within the ResolverMap to fetch data about it from backend services.