Open xunshuairu opened 5 years ago
Apollo iOS requires the __typename
to be available for every object, so I think this is working as intended.
Tested on v2.17.4 and it does not seem to be working either
Version: apollo/2.24.0 darwin-x64 node-v10.16.3
I see the same issue. When __typename
is present the GraphQL deserialization fails from my Apollo server with:
Failure! Error: GraphQLResultError(path:myMutation.__typename, underlying: Apollo.JSONDecodingError.missingValue)
apollo codegen:generate --target=swift --includes="./GraphQL/**/*.graphql" --localSchemaFile="schema.json" --no-addTypename Services/GraphQL
If I manually remove the
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
from the generated code things under
public static let selections: [GraphQLSelection] = [
things start working again.
Here is where this error originates:
https://github.com/apollographql/apollo-ios/blob/master/Sources/Apollo/Decoding.swift#L149-L151
guard let runtimeType = object["__typename"] as? String else {
throw GraphQLResultError(path: path + "__typename", underlying: JSONDecodingError.missingValue)
}
The issue still exists. It doesn't appear to be a tooling issue but more with the apollo-ios. Should it be logged somewhere else for visibility? I am happy to work with someone to resolve this issue.
Code generate
--no-addTypename
is not working forswift
target. Any version <=2.13.1
has this issue. Apollo-iOS example can reproduce.