-
Notifications
You must be signed in to change notification settings - Fork 11
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
Projection of the edges
field on wrapped type
#75
Comments
I completely agree about the responsibility of the "connection" plugin. And I think that we can remove @yoadsn can you try |
You may copy-paste https://unpkg.com/browse/[email protected]/lib/connection.js to your node_modules for fast testing. |
Thanks @nodkz The above fix seems to solve it for the internal connection findMany. I think it's a great improvement. Of course, the extra fields on the top level access (in my example "users" collection) still had all the "posts.edgest.*" flattened projections. As I see it a type (User) was added a relation (to [Post] on the fields "posts") using a "connection" resolver which took care of the projection cleanup all the levels below it. Where should such cleanup be if we built it? I don't know. |
@nodkz Should we at least close the fix on this plugin since it's already providing great benefit as-is? |
@yoadsn can you provide a repro case of your problem? PS. A new version will be published in minutes. |
@nodkz Thank you so much! (This sandbox is so convenient). Here is a very small repro using the User and Post schemas I mentioned in my original example. query example {
users(limit: 1) {
name
posts {
edges {
node {
title
}
}
}
}
} The queries on the DB are:
And I was referring to the |
@nodkz Funny - we talked about this already back in 2016 :)
So now that the mongoose composter flattens the projection to improve performance - it also flattens the non required fields from the connection structure.
This means that for schema
Post { title }
andUser { posts }
whereposts
is a connection you would get for a query:{ user { posts { edges { node { title } } } } }
This projection on mongodb "posts" collection find:
{ 'edges.node.title': true, title: true }
Also, on the "users" collection you can expect this find projection:
{'posts.edges.nodes.title': true }
This used to be a small problem since there was no "flattening" so "edges" would be the only wrong field used. now it's much more. The more fields are used from the connected type the more duplication exists. I am not sure if mongodb has any performance implications but it might.
Since i know for sure my schema is not using "edges" and "node" fields on internal types - I wanted to remove this.
I thought of working around this in multiple ways:
allowEdgeNodeFieldsInProjection
which by default is off.What do you think - I revisited all the code involved but could not find a very clean way to let the projection ignore those fields - it must be the responsibility of the "connection" plugin I feel.
The text was updated successfully, but these errors were encountered: