Skip to content

Latest commit

 

History

History
260 lines (155 loc) · 6.47 KB

graphnodeobserver.md

File metadata and controls

260 lines (155 loc) · 6.47 KB

@daostack/clientGlobalsGraphNodeObserver

Class: GraphNodeObserver

handles connections with the Graph

param

Hierarchy

  • GraphNodeObserver

    Arc

Index

Constructors

Properties

Methods

Constructors

constructor

+ new GraphNodeObserver(options: object): GraphNodeObserver

Defined in graphnode.ts:119

Parameters:

options: object

Name Type
graphqlHttpProvider? undefined | string
graphqlSubscribeToQueries? undefined | false | true
graphqlWsProvider? undefined | string

Returns: GraphNodeObserver

Properties

Logger

Logger: GlobalLogger = Logger

Defined in graphnode.ts:117


Optional apolloClient

apolloClient? : ApolloClient‹object›

Defined in graphnode.ts:118


Optional graphqlHttpProvider

graphqlHttpProvider? : undefined | string

Defined in graphnode.ts:115


Optional graphqlSubscribeToQueries

graphqlSubscribeToQueries? : undefined | false | true

Defined in graphnode.ts:119


Optional graphqlWsProvider

graphqlWsProvider? : undefined | string

Defined in graphnode.ts:116

Methods

getObservable

getObservable(query: any, apolloQueryOptions: IApolloQueryOptions): any

Defined in graphnode.ts:145

Given a gql query, will return an observable of query results

Parameters:

Name Type Default Description
query any - a gql query object to execute
apolloQueryOptions IApolloQueryOptions {} options to pass on to Apollo, cf ..

Returns: any

an Observable that will first yield the current result, and yields updates every time the data changes


getObservableList

getObservableList(query: any, itemMap: function, apolloQueryOptions: IApolloQueryOptions): any

Defined in graphnode.ts:246

Returns an observable that:

  • sends a query over http and returns the current list of results
  • subscribes over a websocket to changes, and returns the updated list.

example:

   const query = gql`
   {
     daos {
       id
       address
     }
   }`
   getObservableList(query, (r:any) => new DAO(r.address))

Parameters:

query: any

The query to be run

Default value itemMap: function= (o) => o

(optional) a function that takes elements of the list and creates new objects

▸ (o: object): object | null

Parameters:

Name Type
o object

Default value apolloQueryOptions: IApolloQueryOptions= {}

Returns: any

an Observable


getObservableListWithFilter

getObservableListWithFilter(query: any, itemMap: function, filterFunc: function, apolloQueryOptions: IApolloQueryOptions): any

Defined in graphnode.ts:285

Returns an observable that:

  • sends a query over http and returns the current list of results
  • subscribes over a websocket to changes, and returns the updated list example: const query = gql { daos { id address } } getObservableList(query, (r:any) => new DAO(r.address), filter((r:any) => r.address === "0x1234..."))

Parameters:

query: any

The query to be run

Default value itemMap: function= (o) => o

(optional) a function that takes elements of the list and creates new objects

▸ (o: object): object | null

Parameters:

Name Type
o object

filterFunc: function

▸ (o: object): boolean

Parameters:

Name Type
o object

Default value apolloQueryOptions: IApolloQueryOptions= {}

Returns: any


getObservableObject

getObservableObject(query: any, itemMap: function, apolloQueryOptions: IApolloQueryOptions): any

Defined in graphnode.ts:302

Parameters:

query: any

Default value itemMap: function= (o) => o

▸ (o: object): object | null

Parameters:

Name Type
o object

Default value apolloQueryOptions: IApolloQueryOptions= {}

Returns: any


sendQuery

sendQuery(query: any, apolloQueryOptions: IApolloQueryOptions): Promise‹object›

Defined in graphnode.ts:322

Parameters:

Name Type Default
query any -
apolloQueryOptions IApolloQueryOptions {}

Returns: Promise‹object›