Apollo-ios: Changing converting logic for custom objects

Created on 12 Aug 2020  路  2Comments  路  Source: apollographql/apollo-ios

Hey awesome Apollo team. I have a question related to custom scalar objects.
We are moving towards using GraphQL and I'm trying to adapt it for our requests. The problem occurs whenever I'm trying to convert custom objects from our response.
Our backend is using JSON type for legacy information. Codegen is trying to convert it to a string:
image

Is there any way to specify that we don't want that object to be converted to a string?
For now I know only one solution: pass --passthroughCustomScalars key, but the downside of this approach is that I need to create global typealias or type for with JSON name for the whole project. Is there any way to not convert the object at all so it can convert ANY type or some more specific name like ApolloJSON so in that case name would be more specific?

Most helpful comment

Okay I found codegen Readme file :) At least I can make prefix for custom scalars by passing it with codegen option:

--customScalarsPrefix="Apollo"

All 2 comments

Okay I found codegen Readme file :) At least I can make prefix for custom scalars by passing it with codegen option:

--customScalarsPrefix="Apollo"

Yep, there's also a namespace option that wraps all your stuff in a big enum to namespace it.

Was this page helpful?
0 / 5 - 0 ratings