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
Add real path to ResolveInfo
#1345
Comments
Consider that without aliases, the "real path" can be ambiguous or have conflicts. {
foo: bar {
qux
}
baz: bar(arg: 3) {
qwak
}
} I would not change existing functionality, but could see the addition of another API that allows retrieving the unaliased path. |
So next to a |
If possible, I would like to see it implemented as a method in order to calculate it lazily. And I would call it |
To calculate it lazily, what's the best approach? I was thinking to add a method to It feels nasty to me. Are there plans for v16 where we can break this behavior? And make it so that |
If lazy calculation is tricky and eager addition is easy and cheap, we can also add it as a property, I am not totally against that. My guess is that having two separate, simple lists is better. I don't see a scenario where one would care about aliases for some parts of the path - either you want aliases or you do not. A list of strings is easier to work with. |
Implemented in #1548 |
I'd like to be able to get the real (trusted) path in
ResolveInfo
next to the untrusted aliased path.Similar to what was written in #412.
ResolveInfo->path
will containmyAlias.myOtherAlias
instead ofactor.movies
.Why is this useful? It can be used to quickly log the path of a requested field. For example, when somebody does not have access. By logging the real path, you never have to guess what it was. Also, it allows trusting the path because it cannot be spoofed.
What would be the best way to implement this? I tried adding an additional
safePath
to ResolveInfo, but that requires many changes in ReferenceExecutor.Another way could be to introduce a
PathAlias
value object that holds the alias + field name. For example:So
ResolveInfo->path
could become[PathAlias('myAlias', 'actor'), PathAlias('myOtherAlias', 'movie'), 'some', 'other', 'field']
.We could put this behind a feature flag to not break existing projects that rely on the
ResolveInfo->path
.Another simpler way could be to do this:
This would produce
['myAlias: actor', 'myOtherAlias: movies']
.What do you think? I'd be happy to work on a PR to get this improved.
The text was updated successfully, but these errors were encountered: