-
Notifications
You must be signed in to change notification settings - Fork 222
Problem with aliases on paginated fields #126
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
Comments
@wmdmark Ah I see. This is a bug indeed. I did an optimization that allows calls to the same field to be merged together. However, I forgot to diff the arguments before attempting to merge the fields. The second call to |
@acarl005 just checking to see what the status of this one is. I know you're probably super busy so I'm happy to help if you can point me in the right direction. Thanks for all your work on join monster, it's been working great for us so far! |
This is actually a pretty rough fix. One of the fundamental assumptions made from the beginning is problematic and is blocking progress. The assumption is that the hydrated data will be placed on an object property with the same name as the field name. This is so In order to fix this, Join Monster can no longer depend on the default resolver. The two (different) results from that field must be retrieved by a custom resolver, and each invocation of the resolver needs to know what the right property name is in the hydrated data, as it can no longer be assumed to be the field name. I cannot estimate how long fixing this would take, as Join Monster would need to be re-thought. Perhaps you can work around it ? {
school {
# make private resources and public resources separate fields
privateResources(first: 1) {
edges {
node {
id
}
}
}
publicResources(first: 1) {
edges {
node {
id
}
}
}
}
} This may be repetitive, but it should work. |
Thanks for the update. Bummer that full support for GraphQL aliases isn't possible but I understand the dilemma. Interestingly, when I moved the |
A fix for this is now possible. Facebook's Such a change will incur a slight increase in configuration overhead and break interface. It will also need graphql-js |
I've debug it for 10 hours, unfortunately I can't figure out how to resolve field with alias name instead of original field name, I were able to fix the query handling and getting the needed data in a perfect way but then the response coming with null instead of taking the data from aliased names on data object. Any expectations about this bug resolution? Let's put some effort together and figure it out, it's really annoying bug :( |
We make heavy use of filter params for our GQL connections, so having the fields resolved with the alias name would help a lot. Adding more fields on the schema level just to filter our data is a bummer. |
still not fixed :( version 2.0.16 |
I've been thinking about this and technically these are two queries and thus should result in two database queries. When this happens, perhaps we can spawn some kind of "Super SQL AST node" indicating an entrypoint into a new query. |
We should discuss more about the solution so if anyone can help they can take a look! |
The problem doesn't seem to be specific to paginated queries, it also happens when you do not paginate. Could someone fix the title of the issue? |
Hello there. This is an issue that I think many of us are still seeing unfortunately. By the sound of it, it looks like a pretty difficult issue. I took a peek and can see why. What are your thoughts on adding a fix that requires a custom resolver? Even if its just to support aliases. I don't know if it covers all of the edge-cases or if its the best solution, but its one way that seemed to help support this. The one thing that I am kind of concerned about by not addressing this bug is that the issue is 'hidden'. Aliases are a pretty normal use case. I know at least a few of us have spent quite a bit of time debugging our queries before finding that's its a bug here. I haven't quite got the project building yet locally, but I can help look into this if needed. There is also a second issue open at #481 that has a pretty similar solution to where I was headed. Thanks! |
I am planning on tackling this again in the next few days, after my first workaround in #481 unfortunately broke other things. |
I opened a PR for this issue: #482 |
I'm running into an issue where I have a paginated field with filter arguments that is being aliased to produce two different result trees. The problem is that both result trees end up coming back with the same result (whatever the last alias resolves to).
I can replicate this issue on the pagination demo as well.
Here's my query:
When this comes back, both
privateCourses
andpublicCourses
are set to the same result (the latter).The query join monster generates looks like this:
Here's the relevant debug output in case it helps:
The text was updated successfully, but these errors were encountered: