-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[FEAT] Default GraphQL DataProvider cannot function on deeper graphs #5943
Comments
Hey @jamesdh this sounds like a good idea in general. I'm not sure about extracting multiple objects into a single response, because that would cache different responses into same resource key. Would you like to work on this? |
Hey @jamesdh looking forward to your PR! That would be really useful. |
Hey @jamesdh, any updates on this one? We'll be happy to help if you had any issues or didn't had time to spare. If you can come up with a draft PR, maybe someone else can continue or Refine team can help finishing it 🙏 |
Is your feature request related to a problem? Please describe.
Currently, the default GraphQL DataProvider is not capable of handling complex object graphs (which is very common in GraphQL). It appears to make the assumption that any query will be designed such that it returns the intended data type at the root level of the response. But this is very frequently not the case with GraphQL.
E.g.
But as is typically the case with GraphQL endpoints, they may not expose highly focused queries such as that, and you may have something along the lines of this, which is still very simplistic but contains the desired data only a single level deeper.
Unfortunately this is not possible with the current DataProvider.
Describe alternatives you've considered
I propose amending the GraphQLQueryOptions type with a
gqlDataPath
and agqlCountPath
properties. These would be an array of strings that tell the DataProvider how to reach the intended data from the response.An additional utils function could be added that would then take this path (if provided) and extract the intended object(s) for use in the response, e.g...
Then the returned result could be derived as so...
Additional context
No response
Describe the thing to improve
This gives the default GraphQL DataProvider the ability to handle more than the most basic of response types. In my experience, one of the primary purposes of graphQL is to expose deeper, more complex graphs of data precisely because the data owners may not be aware of how clients intend to use it. It's likely not possible to expose rudimentary endpoints for every possible use case. GitHub's GraphQL endpoint is an excellent example of this.
The text was updated successfully, but these errors were encountered: