You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a data fetching component that wraps a NerdGraph request like the following (currently only accessible in the Product schema, but to be released in some modified form later in the year).
{
actor {
nerdStorageVault {
secret(name: "my-token")
}
}
}
UserSecretQuery
Query Storage Vault (i.e. secrets encrypted at rest) for user scoped secrets.
Retrieve a secret by name.
Declarative query
//retrieve and use a stored secretimport{UserSecretQuery}from'@newrelic/nr1-community';//SomeOutsideDataComponent takes a token and makes an external callimport{SomeOutsideDataComponent}from'./SomeOutsideDataComponent';<UserSecretQuerysecret="outside_token">{({ loading, error, data })=>{if(loading){return<Spinner/>;}if(error){return'Error!';}const{ outside_token }=data;return<SomeOutsideDataComponenttoken={outside_token}/>;}}</UserSecretQuery>;
Imperative query
UserSecretQuery.query({secret: 'mytoken'}).then(({ data })=>console.log(data));
Props
prop
REQUIRED
type
description
children
TRUE
function
Render prop function as a child.
secret
TRUE
string
Name of secret for search
The text was updated successfully, but these errors were encountered:
It would be awesome to provide a hook for this as well (once we upgrade React 🤞):
// get a specific secret (my_token)const[token,loading]=useUserSecretQuery('my_token');returnloading
? <Spinner/>
: <div>Your secret: {token}</div>;
// get all secretsconst[secrets,loading]=useUserSecretQuery();returnloading
? <Spinner/>
: <ul>{secrets.map((secret,i)=><likey={i}>{secret}</li>)}</ul>;
Create a data fetching component that wraps a NerdGraph request like the following (currently only accessible in the Product schema, but to be released in some modified form later in the year).
UserSecretQuery
Query Storage Vault (i.e. secrets encrypted at rest) for user scoped secrets.
Retrieve a secret by name.
Declarative query
Imperative query
Props
The text was updated successfully, but these errors were encountered: