@daostack/client › Globals › GraphNodeObserver
handles connections with the Graph
param
-
GraphNodeObserver
↳ Arc
+ 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
• Logger: GlobalLogger = Logger
Defined in graphnode.ts:117
• apolloClient? : ApolloClient‹object›
Defined in graphnode.ts:118
• graphqlHttpProvider? : undefined | string
Defined in graphnode.ts:115
• graphqlSubscribeToQueries? : undefined | false | true
Defined in graphnode.ts:119
• graphqlWsProvider? : undefined | string
Defined in graphnode.ts:116
▸ 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(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(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(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(query
: any, apolloQueryOptions
: IApolloQueryOptions): Promise‹object›
Defined in graphnode.ts:322
Parameters:
Name | Type | Default |
---|---|---|
query |
any | - |
apolloQueryOptions |
IApolloQueryOptions | {} |
Returns: Promise‹object›