graphql schema example
Hi.
I am trying to create my own graphql backend based on the graphql dataprovider that is provided by refine.
Is there any graphql.schema example I can use for this purpose?
7 Replies
Hi @_nirock. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, you can refer to the refine GraphQL documentation (https://refine.dev/docs/guides-and-concepts/data-provider/graphql/) for more information on using GraphQL with refine.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@335790220425297921> kapa.ai is still learning and improving, please let us how it did by reacting below
sunny-green•2y ago
Okay. I have just found that the Graphql dataprovider is very, very basic and doesn't even support pagination.
rare-sapphire•2y ago
it has support pagination for pagination. if you found any missing feature please don't hesitate to open feature request on GitHub 🙏🏻
sunny-green•2y ago
Please see line 44:
https://github.com/refinedev/refine/blob/next/packages/graphql/src/dataProvider/index.ts#L44
The total counter is extracted from the received data. That means it will always return a number that is
<= pagesize
.
I believe the graphql dataprovider is not production ready, but if I am missing anything please let me know.GitHub
refine/index.ts at next · refinedev/refine
Build your React-based CRUD applications, without constraints. - refine/index.ts at next · refinedev/refine
rare-sapphire•2y ago
In this case, if the API does not return JSON in this format, then yes, pagination will not work. I suggest creating a data provider based on the needs of your own API.
Our GraphQL data provider is like a boilerplate example.
We also have Strapi-v4 and Hasura GraphQL data providers that work perfectly fine. However, if you have your own API, you can fork this example and customize it according to your needs.
sunny-green•2y ago
The problem is different.
Usually the data comes from one operation (Posts) and the total counter comes from another operation such as PostsMetadata.
This way, we can pull 10 entries, but get the total number of entries.
In this
graphql
adapter, it doesn't get a Metadata
information, and in the total
field it returns the number of entries pulled under this specific iteration.
Strapi-v4 and Hasura Graphql does that properly.
I am at a phase in the project where I can choose the Schema, so I am wondering if it will be a good idea to just mimic the Hasura or Strapi schema...