Skip to content
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

Issue with useList integration with Hasura v3 #6627

Open
socheatleang opened this issue Jan 3, 2025 · 2 comments
Open

Issue with useList integration with Hasura v3 #6627

socheatleang opened this issue Jan 3, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@socheatleang
Copy link

Describe the bug

Hello Refine.dev Team,

I am experiencing an issue where the useList hook does not work properly with Hasura v3. Specifically, the query structure provided by Hasura v3 differs from the expected structure for the Refine.dev Hasura integration.

Just question, would the hasura sdk from refinedev has up to date with the Hasura V3 yet?

Steps To Reproduce

  1. Install @refinedev/hasura
  2. Set up Hasura v3 with a blogs query and the blogsAggregate field.
  3. Use the useList hook in your Refine app to query the blogs resource.
  4. Run the app, and you should see the issue where the query fails or doesn't work as expected due to the mismatch in naming conventions (blogsAggregate vs blogs_aggregate).

Expected behavior

  • The useList hook should be able to properly query the blogs resource using the correct query structure.
  • The aggregation should be handled with the blogs_aggregate field as expected by the Refine.dev Hasura integration.
  • The query should successfully return the list of blogs with the correct count from the aggregation, without errors related to the field naming convention.

Actual Behavior:

  • The query fails or returns incorrect results because useList expects the blogs_aggregate field, but Hasura v3 uses blogsAggregate.
  • The mismatch in field names causes the query to not function as expected.

Packages

  • "@refinedev/react-table": "^5.6.6"
  • "@refinedev/core": "^4.47.1"
  • "@refinedev/hasura": "^6.6.10"

Additional Context

Expected Query for @refinedev/hasura:

export const BLOGS_QUERY = gql`
  query Bloges($limit: Int, $offset: Int) {
    bloges(limit: $limit, offset: $offset) {
      createdAt
      description
      id
      imageUrl
      name
      sequence
      status
      updatedAt
      website
    }
    bloges_aggregate {
      aggregate {
        count
      }
    }
  }
`;

Hasura V3 Query:

query Bloges($limit: Int, $offset: Int) {
  bloges(limit: $limit, offset: $offset) {
    createdAt
    description
    id
    imageUrl
    name
    sequence
    status
    updatedAt
    website
  }
  blogesAggregate {
    _count
  }
}
@socheatleang socheatleang added the bug Something isn't working label Jan 3, 2025
@aliemir
Copy link
Member

aliemir commented Jan 3, 2025

Hey @socheatleang, sorry for the issue. You can pass provider options to change the naming convention.

import dataProvider from "@refinedev/hasura";

const client = /*...*/

const hasuraDataProvider = dataProvider(client, { namingConvention: "graphql-default" });

return (
<Refine
  dataProvider={hasuraDataProvider}
>
  /*...*/
</Refine>
);

By default it's "hasura-default" and it uses snake_case. 🤖

@socheatleang
Copy link
Author

Thanks to help me on this. @aliemir

It's pretty work fine. But it seems like not 100% work.

Now i am having this.

TypeError: Cannot read properties of undefined (reading 'count')
    at getList

Do you have any input about this?
brillion thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants