More complex data models / data types examples?
We are building a project where we have an object with sub types, where each subtype will have unique fields. In other project's we've solved this using graphql inline fragments https://spec.graphql.org/June2018/#sec-Inline-Fragments
I was wondering if there are any examples in Refine for these kinds of more advanced and complex usecases?
4 Replies
Hi @a_c_m. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, there isn't a specific example that directly addresses complex data models with subtypes using inline fragments in Refine. However, I can provide some relevant information that might be helpful for your use case.
Refine does support GraphQL and allows for more advanced querying capabilities. The GraphQL data provider documentation mentions that Refine has a GraphQL data provider, which could potentially be used to handle more complex data structures.
For handling custom GraphQL variables and more advanced filtering, Refine offers the
gqlVariables
property in the GraphQLQueryOptions
. This feature is supported in some data providers like Hasura, as mentioned in the handling filters documentation.
While there isn't a direct example of using inline fragments, you might be able to adapt the GraphQL data provider to work with your complex data model. You could potentially use the gqlVariables
or custom queries to handle your specific use case.
If you need more specific guidance on implementing this in Refine, you might want to check the Refine documentation or reach out to the Refine community for more tailored advice. The Refine team is also open to feature requests and improvements, so you could potentially suggest this as a feature or contribute to the project if you develop a solution.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@703579194784874506> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
sunny-greenOP•2mo ago
A good usecase could be a store, with products - you have a base product object, but then stub types for shoes, or phones, or laptops which would have their own specific fields.
optimistic-gold•2mo ago
Hey @a_c_m you can use our graphql data provider and use your graphql queries by passing them to the individual hooks. You can also use fragments and inline them into your queries. We have
data-provider-graphql
and data-provider-nestjs-query
examples you can check.
https://github.com/refinedev/refine/blob/main/examples/data-provider-graphqlGitHub
refine/examples/data-provider-graphql at main · refinedev/refine
A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility. - refinedev/refine