apollo-ios: Incorrect code generation: String instead of Int
Steps to reproduce:
- Use the schema from: https://github.com/commercetools/commercetools-sunrise-ios/blob/issues/%2394-product-graphql/Sunrise/schema.json
- The only query used was: https://github.com/commercetools/commercetools-sunrise-ios/blob/issues/%2394-product-graphql/Sunrise/Models/Queries/ProductOverview.graphql
The resulting API.swift
that was generated using apollo-ios
version 0.4 and apollo-codegen
version 0.9 contains: public let centAmount: String
(MoneyDetails
struct property). The actual type from the schema:
{
"name": "centAmount",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Long",
"ofType": null
}
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 27 (14 by maintainers)
Commits related to this issue
- split: apollo-ios - PR #23 - Updating contributing guides git-subtree-dir: apollo-ios git-subtree-mainline: 335653a48eadc8e87f2b6e79277139778bf19a63 git-subtree-split: 742648511708e0921554e1d2898847f... — committed to apollographql/apollo-ios by deleted user 10 months ago
- split: apollo-ios-codegen - PR #23 - Updating contributing guides git-subtree-dir: apollo-ios-codegen git-subtree-mainline: 97618d5b56015854664521fb272dfe9260439a67 git-subtree-split: 48b6461c7a4868c... — committed to apollographql/apollo-ios by deleted user 10 months ago
@NiltiakSivad I dug a little deeper, and I found that Apollo CLI now expects the parameter this way:
--passthroughCustomScalars
.You can check out Apollo CLI’s other parameters here: https://github.com/apollographql/apollo-cli#apollo-codegengenerate-output
Hope this helps you 😃
I hope to add better support for custom scalars soon, but in the meantime there is a temporary
apollo-codegen
option--passthrough-custom-scalars
that doesn’t attempt to map custom scalars to string but keeps them as is. That means you’re responsible for defining the type and making sure it isJSONDecodable
andJSONEncodable
.I haven’t tested it, but something like this should work: