Open spion opened 1 year ago
Do you by chance have any repo I can test out?
I found a way to make it work:
function lowerFirst(s: string) {
if (s.length < 1) return s
return s.charAt(0).toLowerCase() + s.substring(1)
}
type Resource = { name: string }
const introspectionOptions = {
include: ["Surveys", "SurveyAccess", "Users"],
operationNames: {
[GET_LIST]: (resource: Resource) => `${lowerFirst(resource.name)}`,
[GET_ONE]: (resource: Resource) => `${lowerFirst(resource.name)}`,
[GET_MANY]: (resource: Resource) => `${lowerFirst(resource.name)}`,
[GET_MANY_REFERENCE]: (resource: Resource) =>
`${lowerFirst(resource.name)}`,
[CREATE]: (resource: Resource) => `insert${resource.name}`,
[UPDATE]: (resource: Resource) => `update${resource.name}`,
[UPDATE_MANY]: (resource: Resource) => `update${resource.name}`,
[DELETE]: (resource: Resource) => `delete${resource.name}`,
[DELETE_MANY]: (resource: Resource) => `delete${resource.name}`,
},
}
useEffect(() => {
if (!client) return
const buildDataProvider = async () => {
const _dataProvider = await buildHasuraProvider(
{
client,
introspection: introspectionOptions,
},
{
aggregateFieldName(resourceName) {
return `${lowerFirst(resourceName)}Aggregate`
},
},
)
setDataProvider(() => _dataProvider)
}
void buildDataProvider()
}, [client])
Thanks @cassus that works great!
I tried to do this by modifying the operation template
However this is insufficient as relationships such as e.g.
otherEntity
cannot be found