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
.asThing returns nil within fragments #2980
Comments
Thanks so so much for the detailed bug report, especially the specific reproduction case and unit test. We'll look into this as soon as we can! |
Thanks for the work on this @AnthonyMDev! The test I gave now passes, so good signs there, but I can't verify for sure if this solves my issue in my real project, as I'm now hitting this crash in codegen: |
Thanks for checking! Just to confirm, the codegen has been rebuilt with |
Yeah, seems like it could be the same issue described here actually, as I'm doing the same
|
I'm not able to reproduce this bug in any of our example projects yet. Would you be able to see which one of your operations is causing this and try to isolate a subsection of your schema and operation to send me that reproduces this? Depending on the complexity of your schema, that may easy or a lot of trouble. If that's not viable, even just sharing the operation might give me a hint as to what edge case circumstances are causing this crash to trigger. |
Ah that helps! Thanks! |
One difference to note is that I'm getting this just in regular code generation though - not mocks. If you are having trouble reproducing this, I can see what I can do to help, but that's probably a conversation best left in the other issue 😄 |
Yeah, I noticed that! A reproduction case would be so helpful! If we can't get one together I'll keep digging though. |
Okay @dafurman, |
Nice! Looks like everything's good on my end so far with codegen from the other issue's fix, and casting in this when branching from |
Summary
While migrating from Apollo 0.53.0's
makeThing()
functions, I've found that.asThing
properties return nil within fragments, which is a blocker for my migration to Apollo 1.x:Narrowing it down, this seems to happen right here, with this returning
false
:apollo-ios/Sources/ApolloAPI/DataDict.swift
Line 73 in 6b3e7cb
This seems to happen due to a mismatch of types between
_data["__fulfilled"]
and__mergedSources
in selection sets.Here's an example of such a mismatch (see repro steps for more context on these types):
If it doesn't break anything else, it seems like the fragment-based type in
__mergedSources
could just be generated asSelf.self
instead to resolve this.Version
1.1.2
Steps to reproduce the behavior
git clone https://github.com/dafurman/apollo-ios.git && git checkout David/myThingCasting
and explore the behavior ofStarWarsServerTests.testCustomHeroGood()
andStarWarsServerTests.testCustomHeroBad()
Or
.graphql
file or any existing one within https://github.com/apollographql/apollo-ios/tree/main/Sources/StarWarsAPI/starwars-graphqlSources/StarWarsAPI/StarWarsAPI/Sources/Operations/Queries/CustomHeroBadQuery.graphql.swift
Sources/StarWarsAPI/StarWarsAPI/Sources/Operations/Queries/CustomHeroGoodQuery.graphql.swift
Sources/StarWarsAPI/StarWarsAPI/Sources/Fragments/CharacterFragment.graphql.swift
Logs
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: