Query a list of entities by their GUIDs.
You can fetch a maximum of 25 entities in one query.
Usage
import { EntitiesByGuidsQuery } from 'nr1'
Examples
Declarative Query
1<EntitiesByGuidsQuery2 entityGuids={[3 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzIx',4 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzUz',5 ]}6>7 {({ loading, error, data }) => {8 if (loading) {9 return <Spinner />;10 }1112 if (error) {13 return 'Error!';14 }1516 return (17 <List items={data.entities} rowHeight={20}>18 {({ item }) => <ListItem key={item.guid}>{item.name}</ListItem>}19 </List>20 );21 }}22</EntitiesByGuidsQuery>;
Imperative query
1EntitiesByGuidsQuery.query({2 entityGuids: [3 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzIx',4 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzUz',5 ],6}).then(({ data }) => console.log(data));
Props
Render prop function as a child.
function (queryResult: {Object // Results of the query.
) => undefined
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`;
GUID of the entities to query.
EntitiesByGuidsQuery .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 ofEntitiesByGuidsQuery.FETCH_POLICY_TYPE.CACHE_AND_NETWORK,EntitiesByGuidsQuery.FETCH_POLICY_TYPE.CACHE_FIRST,EntitiesByGuidsQuery.FETCH_POLICY_TYPE.CACHE_ONLY,EntitiesByGuidsQuery.FETCH_POLICY_TYPE.NETWORK_ONLY,EntitiesByGuidsQuery.FETCH_POLICY_TYPE.NO_CACHE,>
false
true
If true
, the returned entities include their tags.
0
Interval in milliseconds to poll for new data.
Methods
EntitiesByGuidsQuery.render
function () => undefined
EntitiesByGuidsQuery.query
Static method to use EntitiesByGuidsQuery as a Promise instead of as a React component.
function (props: Object // Object containing the query options. Any
EntitiesByGuidsQuery
prop is a valid 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.
}