'react-admin extend dataprovider - graphql - hasura
I need to extend the graphql/hasura dataprovider in order to have a custom method
all other methods shold work as normally expected from this dataprovider
i've this error dataProvider.getList is not a function in the fallback part (in the else part)
this is my code:
import React, {useState, useEffect} from 'react';
import {Admin, Resource, ListGuesser, EditGuesser} from 'react-admin';
import buildHasuraProvider from 'ra-data-hasura'
import authProvider from './authProvider';
import { ComunicazioniCreate, ComunicazioniEdit } from './comunicazioni'
import Dashboard from './Dashboard';
function App() {
const [dataProvider, setDataProvider] = useState(null);
useEffect(() => {
const buildDataProvider = async () => {
//se non dovevo passare l'autenticazione era sufficente questo
const dataProvider = await buildHasuraProvider({
clientOptions: { uri: 'http://localhost:8080/v1/graphql' }
});
const extendeDataProvider = {
...dataProvider,
getList: (resource, params) => {
if (resource === 'apikeys') {
console.log("implement this method");
} else {
// fallback to the default implementation
return dataProvider.getList(resource, params);
}
}
}
setDataProvider(() => extendeDataProvider);
};
buildDataProvider();
}, []);
if (!dataProvider) return <p>Loading...</p>;
return (
<Admin
dashboard={Dashboard} //homepage
dataProvider={dataProvider}
>
<Resource name="comunicazioni" list={ListGuesser} edit={ComunicazioniEdit} create={ComunicazioniCreate} />
</Admin>
)
}
export default App;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
