-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Do not add __typename to @client selection sets @export-ed as input variables. #4784
Do not add __typename to @client selection sets @export-ed as input variables. #4784
Conversation
@OurMajesty @supercranky Does the test included in this commit capture your use case(s) from #4691? |
if ( | ||
isField(field) && | ||
field.directives && | ||
field.directives.some(d => d.name.value === 'export') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hwillson Should this test be stricter? For example, we could require that the directive has an as
argument that refers to a declared variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjamn I think it's okay like this. If we need to change this in the future, we should be able to pretty easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work in the case where the field contains nested fields:
filters @client @export(as: "filters") {
priceFilters {
value
}
The typename will be removed from filters
, but not from priceFilters
.
I have been using this workaround, but it seems undesirable:
filters @client @export(as: "filters") {
priceFilters @export {
value
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @benjamn - thanks!
Here's the exact request from the real application that caused the error: #import 'graphql/fragments/Attachment'
#import 'graphql/fragments/Product'
query GetProducts($filter: ProductFilter, $limit: Int!, $offset: Int!) {
currentFilter @client @export(as: "filter") {
active
recursiveCategoryId
state {
in
}
valid
}
productList(filter: $filter, limit: $limit, offset: $offset) {
totalCount
resultList {
...ProductFields
client {
id
inn
kpp
name
clientName @client
}
images {
...AttachmentFields
}
}
}
} I don't think it have important differences, but maybe it's helpful. |
Fixes #4691.