Skip to content
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

[v3] Cache should not add __typename to @export-ed input variables #7421

Closed
changLiuUNSW opened this issue Dec 7, 2020 · 4 comments
Closed

Comments

@changLiuUNSW
Copy link

changLiuUNSW commented Dec 7, 2020

Intended outcome:
Non-scalar @export-ed variables should be send to the server without adding a __typename field, because input types do not have a __typename field.

Actual outcome:
Server responds with Field "__typename" is not defined.

The query:


mutation submitLead($input: LeadInput) {
    lead @client @export(as: "input") {
      id
      industry
      industryCategory
    }
    submitLead(input: $input) {
      id
    }
  }

current in the cache:

{
"__typename":"Lead",
"id":"00ea1100-797a-456f-900c-61acf15f15d6",
"industry":"Health",
"industryCategory":"Other Health Services"
}

Error:

Error: Variable '$input' is invalid. Unrecognized input fields '__typename' for type 'LeadInput'.

Versions
"@apollo/client": "^3.3.2".

Actually I have seen a similar issue
#4691
And it has been fixed in
#4784

I am not sure why the issue comes back in Apollo client v3

@benjamn
Copy link
Member

benjamn commented Dec 7, 2020

@hwillson @jcreighton @martijnwalraven What do you think about making HttpLink automatically strip __typename from variables, to stop this kind of problem in all cases?

@hwillson
Copy link
Member

Sorry for the delay in responding @benjamn:

What do you think about making HttpLink automatically strip __typename from variables, to stop this kind of problem in all cases?

I'm 👍 on this, especially knowing that if stripping __typename from variables is a problem for anyone, they can create a custom link that doesn't.

@phryneas
Copy link
Member

Actually, this is a feature now - since Apollo Client 3.8 we are shipping the removeTypeName link.

I guess with that, we can close this issue :)

Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants