Query entities by entityDomain and entityType.
Usage
import { EntitiesByDomainTypeQuery } from 'nr1'
Examples
Declarative query
1<EntitiesByDomainTypeQuery entityDomain="APM" entityType="APPLICATION">2 {({ error, data, fetchMore }) => {3 if (error) {4 return 'Error!';5 }67 return (8 <List9 items={data.entities}10 rowCount={data.count}11 rowHeight={20}12 onLoadMore={fetchMore}13 >14 {({ item }) => <ListItem key={item.guid}>{item.name}</ListItem>}15 </List>16 );17 }}18</EntitiesByDomainTypeQuery>;
Fetch with sorting criteria
1<EntitiesByDomainTypeQuery2 entityDomain="INFRA"3 entityType="HOST"4 sortBy={[EntitySearchQuery.SORT_TYPE.ALERT_SEVERITY]}5>6 {({ data, error, fetchMore }) => {7 if (error) {8 return 'Error!';9 }1011 return (12 <List13 items={data.entities}14 rowCount={data.count}15 rowHeight={20}16 onLoadMore={fetchMore}17 >18 {({ item }) => <ListItem key={item.guid}>{item.name}</ListItem>}19 </List>20 );21 }}22</EntitiesByDomainTypeQuery>;
Imperative query
1EntitiesByDomainTypeQuery.query({2 entityDomain: 'APM',3 entityType: 'APPLICATION',4}).then(({ data }) => console.log(data));
Fetch more results using imperative query
1const firstPage = await EntitiesByDomainTypeQuery.query({2 entityDomain: 'APM',3 entityType: 'APPLICATION',4});56console.log('First page data', firstPage.data);78const cursor = firstPage.data.nextCursor;9const secondPage = await EntitiesByDomainTypeQuery.query({10 cursor,11 entityDomain: 'APM',12 entityType: 'APPLICATION',13});1415console.log('Second page data', secondPage.data);1617// NOTE: To fetch multiple page results consecutively,18// use EntitiesByDomainTypeQuery component's fetchMore approach.
Props
Render prop function as a child.
function (queryResult: {Object // Results of the query.
) => undefined
Domain of the entities you want to query.
GraphQL fragment document parsed into an AST by graphql-tag
.
The Query components return the most commonly used fields available on an entity. You can use this prop when you want to request additional fields for the entities returned by your query.
The fragment should be named EntityFragmentExtension
and apply to the
EntityOutline
type.
Example 1
1const entityFragmentExtension = ngql`2 fragment EntityFragmentExtension on EntityOutline {3 indexedAt4 guid5 }6`;
Type of the entities you want to query.
EntitiesByDomainTypeQuery .FETCH_POLICY_TYPE .CACHE_AND_NETWORK
Fetch policy to be used for the query.
Allows you to specify how you want your query to interact with the cached data.
CACHE_AND_NETWORK
: The query returns your initial data from the cache if available. However, regardless of whether or not the full data is in your cache, the query always makes a request using your network interface and returns the updated data. This option is not available when using the staticquery()
method of the component.CACHE_FIRST
: The query makes a request using your network interface only if the data for your query is not already in the cache.CACHE_ONLY
: The query never makes a request using your network interface. Instead it returns the data available in the cache. If the data for your query does not exist in the cache, then an error is thrown.NETWORK_ONLY
: The query never returns your initial data from the cache. Instead it always makes a request using your network interface.NO_CACHE
: The query never returns your initial data from the cache. Instead it always makes a request using your network interface. Unlike theNETWORK_ONLY
policy, it does not write any data to the cache after the query completes.
<One ofEntitiesByDomainTypeQuery.FETCH_POLICY_TYPE.CACHE_AND_NETWORK,EntitiesByDomainTypeQuery.FETCH_POLICY_TYPE.CACHE_FIRST,EntitiesByDomainTypeQuery.FETCH_POLICY_TYPE.CACHE_ONLY,EntitiesByDomainTypeQuery.FETCH_POLICY_TYPE.NETWORK_ONLY,EntitiesByDomainTypeQuery.FETCH_POLICY_TYPE.NO_CACHE,>
Filters used to narrow down the entities.
This is an array of filters, and there are 3 possible filters:
SearchQueryFilter:
Object<type: string = "searchQuery", value: string>
EntityTypeFilter:
Object<type: string = "entityType", Object<domain: string, type: string>>
TagFilter:
Object<type: string = "tag", Object<key: string, value: string>>
Example 1
1const filters = [2 {3 type: 'searchQuery',4 value: 'foo',5 },6 {7 type: 'entityType',8 value: { domain: 'APM', type: 'APPLICATION' },9 },10 {11 type: 'tag',12 value: { key: 'environment', value: 'production' },13 },14 {15 type: 'tag',16 value: { key: 'team', value: 'bar' },17 },18];
false
false
If true
, the returned entities include their tags.
0
Interval in milliseconds to poll for new data.
Array of criteras used to sort the entity search results.
<Array of<One ofEntitiesByDomainTypeQuery.SORT_TYPE.ALERT_SEVERITY,EntitiesByDomainTypeQuery.SORT_TYPE.DOMAIN,EntitiesByDomainTypeQuery.SORT_TYPE.MOST_RELEVANT,EntitiesByDomainTypeQuery.SORT_TYPE.NAME,EntitiesByDomainTypeQuery.SORT_TYPE.REPORTING,EntitiesByDomainTypeQuery.SORT_TYPE.TYPE,>
>
Methods
EntitiesByDomainTypeQuery.render
function () => undefined
EntitiesByDomainTypeQuery.query
A static method to use EntitiesByDomainTypeQuery as a Promise instead of a React component.
function (props: Object // An object containing the query options. Any
EntitiesByDomainTypeQuery
prop is valid as an option except
children
and pollInterval
.
) => {Object}
Type definitions
PromiseQueryResult
{loading: boolean, // Indicates that the request is in flight.
data: Object, // An object containing the result of your query.
}