-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for new hasura naming convention (graphql-default) #130
Comments
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! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to do this by modifying the operation template
However this is insufficient as relationships such as e.g.
otherEntity
cannot be foundThe text was updated successfully, but these errors were encountered: