Interroger une liste d’entités par leur GUID.
Vous pouvez récupérer un maximum de 25 entités dans une requête.
Usage
import { EntitiesByGuidsQuery } from 'nr1'
Exemples
Requête déclarative
<EntitiesByGuidsQuery entityGuids={[ 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzIx', 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzUz', ]}> {({ loading, error, data }) => { if (loading) { return <Spinner />; }
if (error) { return 'Error!'; }
return ( <List items={data.entities} rowHeight={20}> {({ item }) => <ListItem key={item.guid}>{item.name}</ListItem>} </List> ); }}</EntitiesByGuidsQuery>
Récupérer avec des critères de tri
<EntitiesByGuidsQuery entityGuids={[ 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzIx', 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzUz', ]} sortType={[EntitiesByGuidsQuery.SORT_TYPE.ALERT_SEVERITY]}> {({ loading, error, data }) => { if (loading) { return <Spinner />; }
if (error) { return 'Error!'; }
return ( <List items={data.entities} rowHeight={20}> {({ item }) => <ListItem key={item.guid}>{item.name}</ListItem>} </List> ); }}</EntitiesByGuidsQuery>
Requête impérative
EntitiesByGuidsQuery.query({ entityGuids: [ 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzIx', 'MTIzNDU2fEZPT3xCQVJ8OTg3NjU0MzUz', ],}).then(({ data }) => console.log(data));
Accessoires
fonction | Rendre la fonction prop comme un enfant. function ( |
objet | Document fragment GraphQL analysé dans un AST par
|
OBLIGATOIREchaîne[] | GUID de l'entité à requêter. |
énum. | Vous permet de spécifier comment vous souhaitez que votre requête interagisse avec les données mises en cache.
|
booléen | |
booléen | Si |
nombre | Intervalle en millisecondes pour interroger de nouvelles données. Réglez à zéro pour éviter tout type d'interrogation régulière. |
booléen | Lorsqu'il est défini sur |
OBSOLÈTE | Date limite de soumission : 1er novembre 2023Le sortBy est obsolète, utilisez plutôt sortType |
énumération[] | Éventail de critères utilisés pour trier les résultats de recherche d'entités. <Array of |
Méthodes
EntitiesByGuidsQuery.query
function (props: Object Object containing the query options. Any EntitiesByGuidsQuery
prop is a valid option except children
and pollInterval
.
) => PromiseQueryResult
Définitions de types
PromiseQueryResult
{error: ApolloClient.ApolloError, Runtime error with graphQLErrors
and networkError
properties.
data: Object, Object containing the result of your query.
fetchMore: function|null, If not null
, fetchMore
allows you to load more results for your query. New data is merged with previous data.
refetch: function, Refetch the query.
}
QueryResult
{loading: boolean, Indicates that the request is in flight.
error: ApolloClient.ApolloError, Runtime error with graphQLErrors
and networkError
properties.
data: Object, Object containing the result of your query.
fetchMore: function|null, If not null
, fetchMore
allows you to load more results for your query. New data is merged with previous data.
refetch: function, Refetch the query.
}