This happens because the on
keyword is a reserved keyword in GraphQL.
One of the Type Conditions is on
NamedType, see the official spec file of GraphQL.
query FragmentTyping {
profiles(handles: ["zuck", "cocacola"]) {
handle
...userFragment
...pageFragment
}
}
fragment userFragment on User {
friends {
count
}
}
fragment pageFragment on Page {
likers {
count
}
}
See the on
used in fragment userFragment on User
? Your GraphQL got confused because you are using on
as a field within the query, while it expects to be a fragment. Read more about fragments here. Also, a fragment's name can be anything, except for on
, see the official spec file.
One way to solve this issue might be to rename the field in your query, but I am not sure if GraphQL will complain about this approach as well:
query TimeLine($inputData: InputData!) {
getTimeLine(inputData: $inputData) {
dataOn: on
updated
}
}