I do not quite understand what the error even is to be able to tackle this problem. Checking server console also doesn't show any descriptive error. I have added all the necessary code that is related to this issue.
Here is the mutation:
mutation SaveTrials($event: ID!, $input: [ResultTrialsInputType!]!) {
saveTrials(event: $event, results: $input) {
results {
id
trials
}
}
}
I am using Graphene (Python) in backend but the types correspond to the following:
input ResultTrialsInputType {
id: ID
person: ID!
trials: [String]
}
Here is the Python code if it matters:
class ResultTrialsInputType(graphene.InputObjectType):
id = graphene.ID()
person = graphene.ID(required=True)
trials = graphene.List(graphene.String)
When I send data from the apollo using the mutation above, this is what is being sent to the API:
{
"operationName": "SaveTrials",
"variables": {
"event": "207e9f27-be66-4564-9c28-ac92ec44235d",
"input": [
{
"id": "8eb80b8b-c93a-44b1-9624-e75436c13780",
"trials": [
"32.1",
"92.2",
"12.1",
"12.2",
"23.2",
""
],
"__typename": "ResultTrialsObjectType",
"person": "a6f18ab5-df23-421e-b916-73e569bf73ad"
}
]
},
"query": "mutation SaveTrials($event: ID!, $input: [ResultTrialsInputType!]!) {\n saveTrials(event: $event, results: $input) {\n results {\n id\n trials\n __typename\n }\n __typename\n }\n}\n"
}
Response for this query is an error about "__typename":
{
"errors": [
{
"message": "Variable \"$input\" got invalid value [{\"__typename\": \"ResultTrialsObjectType\", \"person\": \"a6f18ab5-df23-421e-b916-73e569bf73ad\", \"id\": \"8eb80b8b-c93a-44b1-9624-e75436c13780\", \"trials\": [\"32.1\", \"92.2\", \"12.1\", \"12.2\", \"23.2\", \"\"]}].\nIn element #0: In field \"__typename\": Unknown field.",
"locations": [
{
"line": 1,
"column": 34
}
]
}
]
}
In anywhere else in my application where an input argument is not array of custom objects as expected. What is the deal here? Am I setting my input arguments in the wrong way? Or am I missing something here?
I tried to add __typename
manually to the input type; however, nothing happened.
Thanks!
EDIT: Now that I am checking this out, for some reason __typename
is displayed as ResultTrialsObjectType
but it should be ResultTrialsInputType
. How is this value being generated? Does Apollo generate it or does server generate it and Apollo fetches it?