Skip to content
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

Default to String for custom types that do not have a mapping #173

Closed
martinbonnin opened this issue Feb 9, 2017 · 2 comments
Closed

Default to String for custom types that do not have a mapping #173

martinbonnin opened this issue Feb 9, 2017 · 2 comments
Assignees

Comments

@martinbonnin
Copy link
Contributor

Would be nice if DateTime for an example could by default be readable as a string for users that did not register any custom adapters.

@sav007
Copy link
Contributor

sav007 commented Feb 9, 2017

@martinbonnin It's not so simple.

If we missing adapter but we have mapping configuration in apollo plugin:

customTypeMapping {
        DateTime = "java.util.Date"
    }

compiler generates models with the java.util.Date rather then String. But when we reading response field value of DateTime we are reading it as a String and then we will fail as we can't just assign String to java.util.Date and we don't have the way to convert it.

So the only solution is next: if we missing mapping in apollo plugin (build.gradle), string will be used by default as type in generated models for custom scalar types

@martinbonnin
Copy link
Contributor Author

If there's no adapter, I don't expect anyone to put customTypeMapping in build.gradle. So this would really be a 'zero configuration' thing to make it easier to start using the project.

Agree with using a default return type if no mapping is defined. Maybe use 'Object' instead of 'String' so we could return directly what's in the json ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants