This is a introspection query to get the DataSourceType enums:
{code:javascript} const GET_DATA_SOURCES_NAMES = gql` { __type(name: "DataSourceType") { name states: enumValues { name } } } ` {code}
Using this query:
{code:javascript} const DataSourcesNames = () => { return <Query query={GET_DATA_SOURCES_NAMES}> {({loading, error, data}) => { if (loading) return "Loading..."; if (error) return error.message; const items = data.__type.states.map((item, idx) => { return ( <ListView.Item key={idx} name={item.name} className="ds-list-item" leftContent={<span className="list-item-name">{item.name}</span>} > </ListView.Item> ) }) return ( <div> <ListView> {items} </ListView> </div> ); }} </Query> }; {code}
Then in the DatasourceView Components render function:
{code:javascript} <div> <DataSourcesNames/> </div> {code}
The result of executing the query using graphiql:
{code:javascript} { "data": { "__type": { "name": "DataSourceType", "states": [ { "name": "InMemory" }, { "name": "PostgreSQL" } ] } } } {code} |
|