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
DataFetchingFieldSelectionSet look ahead with aliases #1545
Comments
Thanks for reporting. I think field aliases got lost in the design wash here. We should use the canonical field name for server side fetcher code. We will look into this in the next release |
@bbakerman another issue to keep in mind when we look at using the query execution tree for the field selection. |
Any suggestions if I want to contribute for a fix for this? Where should I start looking? |
Just stumbled upon this issue. Makes it hard for us to optimize our fethers as the queries could use arbitrary aliases |
Hi @hameno, public boolean isFieldRequested(final DataFetchingFieldSelectionSet fetchingFieldSelectionSet) {
return fetchingFieldSelectionSet.getFields().stream()
.filter(selectedField -> "parent".equals(selectedField.getName()))
.map(selectedField -> selectedField.getSelectionSet().getFields())
.flatMap(List::stream)
.filter(graphQLFieldDefinition -> "child".equals(graphQLFieldDefinition.getName()))
.map(selectedField -> selectedField.getSelectionSet().getFields())
.flatMap(List::stream)
.anyMatch(selectedField -> "name".equals(selectedField.getName()));
} |
As a stop-gap, it would at least be nice if the docs on DataFetchingFieldSelectionSet explained that all the field names in its API are response field names (possibly aliased). Would such a PR be accepted, or is the idea that the semantics may actually change? |
Hi @bbakerman @andimarek, |
We are working right now on a better sub selection mechanism. If you look at master right now there is
actually we are NOT going to make this API but rather fold it into the It will include the alias in its data. But it wont be used in the glob matching |
done |
Hi,
It looks like qualifiedName values for fields on DataFetchingFieldSelectionSet are using aliased names instead of schema/type/field names and hence it is hard/impossible to do look ahead to resolve nested fields, boolean contains(String fieldGlobPattern) also matches only aliases and not actual field names. Currently I am using QueryTraversal with my QueryVisitor to build these fields. Would it be possible to add another field or method on fields to have correct path or is there easier way to translate them, so i don't need to do full traversal again?
Thanks,
Reinis
The text was updated successfully, but these errors were encountered: