This is a data provider that connects postgraphile with react admin. It is build on top of ra-data-graphql. n.b. the docs for ra-data-graphql are out of date.
Under active development. Although I am using this library in production, it does not cover the full API of react admin. Please raise an issue if there is something in particular that you need.
Creates a data provider
- Options object * apolloHttpLinkOptions: Options passed to apollo http link. docs here * buildQuery (optional): You can use this to extend ra-postgraphile-client
import buildPostgraphileProvider from 'ra-postgraphile-provider'
const raDataProvider = buildPostgraphileProvider()
import buildPostgraphileProvider from 'ra-postgraphile-provider'
const raDataProvider = buildPostgraphileProvider({
apolloHttpLinkOptions: {
uri: `my-custom-graphql-enpoint.io/graphwhat`
fetch: (url, options) => {
// You can add custom auth logic with a wrapper around fetch
const token = localStorage.getItem('token')
if (!token) {
return ;
} if (jwt.decode(token).exp < Date.now()) {
localStorage.removeItem('token')
return ;
}
const headers = {
...options.headers,
authorization: `bearer ${token}`
}
return fetch(url, ({ ...options, headers }))
}
}
})
You will need to implement an auth provider to handle log in and log out.
- Build out test suite
- Build postgraphile server mocker
- add test script
- build out coverage
- Write readme
- Test on live project
- publish
- Cover all query types
- GET_LIST
- pagination
- sort
- order
- filter
- GET_ONE
- id
- UPDATE
- id
- data
- UPDATE_MANY
- ids
- data
- DELETE
- id
- DELETE_MANY
- ids
- GET_MANY
- ids
- GET_MANY_REFERENCE
- target
- id
- pagination
- perPage
- sort
- filter
- GET_LIST