Closed BreSmit521 closed 5 years ago
Smth not right, it looks like your adapter wasn't added to the client. Is there anyway you can check that ApolloClient instance has this adapter you add? Second guess could you check that generated CustomType.DATETIME
has correct typeName== DateTime
The Apollo Client does have the adapter but the class that's listed is of whatever the parent class the adapter is located in. Also, I did verify the type is correct in the generated Custom Type file
Edit: Uploading Screenshots to make sure we're on the same page:
No breakpoints within the CustomTypeAdapter that I passed in are hitting either. Also, I did try implementations in both Java and Kotlin just to be sure, both had the same results
Is it possible to see generated query and the full stack trace of exception?
I will verify tomorrow. But I do believe I narrowed down the issue. This appears to only happen when the client(s) are injected via Koin. I started a small app from scratch and everything worked as expected then when I moved the Apollo and OkHttpClients to a koin module the error returned.
Edit: Our koin was also in a different module within the project. Looking into that being the cause of the issue as well
Edit 2: This appears to be 100% caused by having multiple modules applying the apollographql plugin. Is there any recommended way to handle having separate app and server modules where the server module contains the apolloclient/schema(s)/custom adapters and then the app module can contain the queries?
@BreSmit521 I made a PR for that exact issue https://github.com/apollographql/apollo-android/pull/1592
I'm kind of waiting for it go get released too. In the meantime, I've added to the server API a addGraphQAdapter()
method so the module can re-register for their own types.
@budius That's awesome news! Thanks a lot for the reply and I will keep an eye on that PR
Version: 1.1.3
Issue: I am receiving a DateTime object from a server and am attempting to parse as a Date but every time the object returns I get a parse exception:
java.lang.IllegalArgumentException: Can't map GraphQL type: DateTime to: class java.util.Date. Did you forget to add custom type adapter?
build.gradle:
apollo { customTypeMapping = ["DateTime": "java.util.Date"] }
ApolloClient:
CustomTypeAdapter (Yes I realize the value on this is not what I'm receiving from server, just trying to get it to work first):
If you need any more information let me know. Thanks in advance.
Edit: Formatting